|
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
|
10-15-2007 20:19
I am getting a syntax error for this statement: yes() { llInstantMessage(user,"You guessed correctly."); if (storage == 1); { score = score + g1; llInstantMessage(user,"Score: " + (string) score); } else if (storage == 2); { score = score + g2; llInstantMessage(user,"Score: " + (string)score); } else if (storage == 3); { score = score + g3; llInstantMessage(user,"Score: " + (string)score); } else if (storage == 4); { score = score + g4; llInstantMessage(user,"Score: " + (string)score); } else if (storage == 5); { score = score + g5; llInstantMessage(user,"Score: " + (string)score); } else if (storage == 6); { score = score + g6; llInstantMessage(user,"Score: " + (string)score); } else if (storage == 7); { score = score + g7; llInstantMessage(user,"Score: " + (string)score); } else if (storage == 8); { score = score + g8; llInstantMessage(user,"Score: " + (string)score); } else if (storage == 9); { score = score + g9; llInstantMessage(user,"Score: " + (string)score); } }
|
|
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
|
10-15-2007 20:26
Too many else ifs
Try:
if (storage == 9); { score = score + g9; llInstantMessage(user,"Score: " + (string)score); return; }
probably the easiest fix
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-15-2007 20:45
I don't know what your g values are and I had to declare some globals to test this. But it will show you a way so that you don't have to use else if tests. list g_values = ["", "25", "93", "76", "150"]; integer storage = 2; integer score= 15; string user = "Jesse"; integer g;
default { touch_start(integer total_number) { if(storage > 0){ g = llList2Integer(g_values, storage); score += g; llInstantMessage(user,"You guessed correctly." + " Score: " + (string)score); } } }
Outputs: InstantMessage(Jesse,You guessed correctly. Score: 10 
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
10-15-2007 22:37
You're putting semicolons at the end of your *if* and *else if* lines, that's what you're doing wrong. Because of this, the first *if* is immediately terminated, then you have a block of code which falls outside the scope of the if condition, hence the following *else ifs* are meaningless to the compiler.
It's as if you had:
if( some_condition ) { // do nothing }
{ // do some other stuff }
else if( some_other_condition ) { // else? else from *what*? }
|
|
Katryna Jie
Registered User
Join date: 24 Jun 2007
Posts: 187
|
10-15-2007 23:16
/me nods... Deanna's right.. there shouldn't be any semi-colons at the end of the if and else if lines
|