Aller au contenu

Photo

struct error: parsing variable list


  • Veuillez vous connecter pour répondre
10 réponses à ce sujet

#1
twopounder

twopounder
  • Members
  • 8 messages
 So, I've created a common struct to pass both an int and a string. All of them work, with the exception of this:

struct MagicProperties getOnHitProp(int oPC_Level)
{
struct MagicProperties OnHitProp;
struct MagicProperties RaceType = getRacialType();

The odd thing is that it DOES work in a different library, but the getRacialType() function is in the SAME library as getOnHitProp().

So, an include would be recursive, the same exact command works in a different library that includes this one, and as far as I know, RaceType is a correct declaration.

The variable is being used as such:

case 20 : OnHitProp.iOnHitType = IP_CONST_ONHIT_SLAYRACE;			  
          OnHitProp.iOnHitclass = RaceType.iRace;			  
          OnHitProp.sOnHitType = RaceType.sRace + " Smiting ";			  break;

Anyone see what I'm doing wrong?

Modifié par twopounder, 31 octobre 2010 - 07:26 .


#2
Olblach

Olblach
  • Members
  • 175 messages
Can't say like this..not enough info... You can always declare getRacialType() if that is an issue (C language right?)... Is OnHitProp initialized somewhere? What (and where) is the error message?

#3
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
I know nothing about structs. But I have to wonder why in the line you posted there is an open brace but no closing brace. Could that be the cause?



Regards

#4
Olblach

Olblach
  • Members
  • 175 messages
Ah yes, I never use structs in script either. However since it's script you really need to have getRacialType() declared before being used. And yes might be the closing brace too.

#5
twopounder

twopounder
  • Members
  • 8 messages
Closing braces are way at the bottom (6 if statements and a ton of cases later)



getRacialType() is a function just below getOnHitProp().



RaceType is a struct variable that is declared in struct MagicProperties RaceType =



It's bizzar.

#6
twopounder

twopounder
  • Members
  • 8 messages
I've added code tags to make it easier to read.

#7
Olblach

Olblach
  • Members
  • 175 messages
OK, try this:



// declaration

struct MagicProperties getRacialType();



struct MagicProperties getOnHitProp(int oPC_Level)

{

struct MagicProperties OnHitProp;

struct MagicProperties RaceType = getRacialType();

#8
twopounder

twopounder
  • Members
  • 8 messages
declaring that outside of the brackets creates a duplicate getRacialType() function...



struct MagicProperties getRacialType() already exists within this library.



//Racial Type Table
struct MagicProperties getRacialType()

{

struct MagicProperties RacialType;
string debug;


switch(Random(24))

	{
		case 0 : RacialType.iRace = IP_CONST_RACIALTYPE_VERMIN; 
					RacialType.sRace = "Vermin";	
		break; 																		
		case 1 : RacialType.iRace = IP_CONST_RACIALTYPE_ABERRATION; 
					RacialType.sRace = "Abberation";
		break; 																
		case 2 : RacialType.iRace = IP_CONST_RACIALTYPE_ANIMAL; 
					RacialType.sRace = "Animal";
		break; 																	
		case 3 : RacialType.iRace = IP_CONST_RACIALTYPE_BEAST; 
					RacialType.sRace = "Beast";
		break; 			
		case 4 : RacialType.iRace = IP_CONST_RACIALTYPE_CONSTRUCT; 
					RacialType.sRace = "Construct";
		break; 		
		case 5 : RacialType.iRace = IP_CONST_RACIALTYPE_DRAGON; 
					RacialType.sRace = "Dragon";
		break; 			
		case 6 : RacialType.iRace = IP_CONST_RACIALTYPE_DWARF; 
					RacialType.sRace = "Dwarf";
		break; 			
		case 7 : RacialType.iRace = IP_CONST_RACIALTYPE_ELEMENTAL; 
					RacialType.sRace = "Elemental";
		break; 		
		case 8 : RacialType.iRace = IP_CONST_RACIALTYPE_ELF; 
					RacialType.sRace = "Elf";
		break; 			
		case 9 : RacialType.iRace = IP_CONST_RACIALTYPE_FEY; 
					RacialType.sRace = "Fey";
		break; 				
		case 10 : RacialType.iRace = IP_CONST_RACIALTYPE_GIANT; 
					RacialType.sRace = "Giant";
		break; 			
		case 11 : RacialType.iRace = IP_CONST_RACIALTYPE_GNOME; 
					RacialType.sRace = "Gnome";
		break; 			
		case 12 : RacialType.iRace = IP_CONST_RACIALTYPE_HALFELF; 
					RacialType.sRace = "Half-Elf";
		break; 		
		case 13 : RacialType.iRace = IP_CONST_RACIALTYPE_HALFLING; 
					RacialType.sRace = "Halfling";
		break; 			
		case 14 : RacialType.iRace = IP_CONST_RACIALTYPE_HALFORC; 
					RacialType.sRace = "Half-Orc";
		break; 		
		case 15 : RacialType.iRace = IP_CONST_RACIALTYPE_HUMAN; 
					RacialType.sRace = "Human";
		break; 				
		case 16 : RacialType.iRace = IP_CONST_RACIALTYPE_HUMANOID_GOBLINOID; 
					RacialType.sRace = "Goblin";
		break; 
		case 17 : RacialType.iRace = IP_CONST_RACIALTYPE_HUMANOID_MONSTROUS; 
					RacialType.sRace = "Monster";
		break; 
		case 18 : RacialType.iRace = IP_CONST_RACIALTYPE_HUMANOID_ORC; 
					RacialType.sRace = "Orc";
		break; 		
		case 19 : RacialType.iRace = IP_CONST_RACIALTYPE_HUMANOID_REPTILIAN; 
					RacialType.sRace = "Lizard";
		break; 
		case 20 : RacialType.iRace = IP_CONST_RACIALTYPE_MAGICAL_BEAST; 
					RacialType.sRace = "Unicorn";
		break; 		
		case 21 : RacialType.iRace = IP_CONST_RACIALTYPE_OUTSIDER; 
					RacialType.sRace = "Outsider";
		break; 			
		case 22 : RacialType.iRace = IP_CONST_RACIALTYPE_SHAPECHANGER; 
					RacialType.sRace = "Shape Changer";
		break; 		
		case 23 : RacialType.iRace = IP_CONST_RACIALTYPE_UNDEAD; 
					RacialType.sRace = "Undead";
		break; 			
		default : debug = "something is wrong, call a DM!"; break;

		}
			return RacialType;
}


#9
Olblach

Olblach
  • Members
  • 175 messages
Then move the whole function definition above getOnHitProp() that should do it.

#10
twopounder

twopounder
  • Members
  • 8 messages
And that worked, as crazy as it is.



Thanks for the help.

#11
Olblach

Olblach
  • Members
  • 175 messages
Thanks to you. I can play with structs in script now^^