what's wrong with this code (missing '}' error)?

Started by Buckethead, Fri 08/09/2006 14:40:25

Previous topic - Next topic

Buckethead

 I feel such a noob posting here again, and again and once again but I'm really stuck again.  ???

I made this code:

Code: ags
if (player.InventoryQuantity[1] == 1) {


// character[EGO].Walk(210,162,eBlock);
character[EGO].Say("I don't feel like taking more stuff out of it");  
 }
 else {

// character[EGO].Walk(210, 162,eBlock );
character[EGO].FaceLocation(210, 162,eBlock);
GiveScore(1);
Display("Adolf Hitler's Moustache, that you got for birthday last year, is lying in the storage. You decide to take it.");
character[EGO].AddInventory(iAHM);


I made it so that if you interact with the hotspot you walk to it and get a inventory item, plus a message saying so.  Then I want it so that if you interact again there is nothing to find anymore.

As far as I got from the manual and tutorials this script should do that. But... It's giving this error:
Quote
There was an error compiling your script. The problem was:
In 'Room 2 script'

Runtiem error: Function still open, missing }
No I thought I might have missed a ' } ' somewhere but when I click 'yes' on fixing the script it goes here:



I'm kinda confused now  ???

thnx in advance  :)

Ashen

#1
If that's all the code you have, the '}' is missing from the end (after the AddInventory command). If there's more (and looking at it, I'd guess there is), check through it yourself - you can use Ctrl-B to match braces - or post the whole thing.

With missing brace errors, it won't take you to the exact line, since - if you had nested conditions for example - it isn't always obvious where the extra brace should go.

Also, can you post error messages as text and not images, as it makes it easier for others with the same problem to search for answers. And, use more descriptive titles in future, please.
I know what you're thinking ... Don't think that.

Buckethead

thnx that worked, I still can't believe such small thing can mess up everything. Anyway thnx alot  :) ;D

Khris

Not really issue-related but worth to mention, I believe.

It's not safe to rely on if (player.InventoryQuantity[...]==1), because as soon as you've used the item somewhere and thus it has been removed from the inventory, you'll be able to obtain it again.
Use GlobalInts or better, global variables, to keep track of things like that.

SMF spam blocked by CleanTalk