Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Cluey on Fri 15/05/2009 13:29:31

Title: Parse errors up the chuffer. Inventory use woes.
Post by: Cluey on Fri 15/05/2009 13:29:31
I'm trying to make a simple puzzle where you have to give a character a book to progress the game.

The script attached to the use inventory on character looks a wee bit like this

if (player.activeinventory = iBook);
  (the rest is the action)

But when I test this, I get a vague "parse error near "player".

There isn't any real documentation on using the use_inv function or the Active Inventory value. So I'm stumped.
Title: Re: Parse errors up the chuffer. Inventory use woes.
Post by: Hudders on Fri 15/05/2009 13:36:11
You need another = sign and to get rid of the semicolon on the end.


if (player.activeinventory == iBook)
Title: Re: Parse errors up the chuffer. Inventory use woes.
Post by: Intense Degree on Fri 15/05/2009 14:06:22
I love the name of this thread, it reads like a really weird cryptic crossword clue! :)
Title: Re: Parse errors up the chuffer. Inventory use woes.
Post by: Trent R on Fri 15/05/2009 17:39:41
Quote from: Cluey on Fri 15/05/2009 13:29:31There isn't any real documentation on using the use_inv function or the Active Inventory value. So I'm stumped.
Actually, there's plenty. But too many newbies (and n00bs) skip over the manual, ending up in the same questions over and over again.

~Trent
Title: Re: Parse errors up the chuffer. Inventory use woes.
Post by: Cluey on Fri 15/05/2009 18:39:29
Quote from: Trent R on Fri 15/05/2009 17:39:41
Quote from: Cluey on Fri 15/05/2009 13:29:31There isn't any real documentation on using the use_inv function or the Active Inventory value. So I'm stumped.
Actually, there's plenty. But too many newbies (and n00bs) skip over the manual, ending up in the same questions over and over again.

~Trent


I've been without internet  for ages in my house, I've been poring over the manual for days and finding little, what should I search for? The page I found on the subject had one = mark.

Thanks for the help anyway.
Title: Re: Parse errors up the chuffer. Inventory use woes.
Post by: Trent R on Fri 15/05/2009 19:44:35
Quote from: Cluey on Fri 15/05/2009 18:39:29I've been without internet  for ages in my house, I've been poring over the manual for days and finding little, what should I search for?
Well, you can always just start reading, whether straight through or jumping through 'See Also' links.


For ActiveInventory, you can search 'inv' in the Index and the second item that pops up is 'Inventory Item events'. It says:
Quote from: ManualYou can use the player.ActiveInventory property to distinguish which item they used.
Which links directly to the ActiveInventory property.

Quote from: Cluey on Fri 15/05/2009 18:39:29The page I found on the subject had one = mark.
I take it you mean the Example on the ActiveInventory entry? Well, if you read what it says,
Quote from: ManualGets/sets the character's current active inventory item. Setting it will update the mouse cursor if appropriate.
Quote from: Manualwill make the inventory item iKey active
Both will tell you that the you can set the ActiveInventory, not just getting it (which is its most common usage). Combine that with basic scripting knowledge (look up Operators if you don't know) and you'll know that you use = for setting (and a semi colon) and == for checking (combined with brackets). This is the reason we don't like script kiddies on the forums that say "Give me teh code!!! Dont point me to a supid manual entry, or RTFM!!" because they don't understand the code that's give to them.

Also, if you had run a forum search, the first result (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37137.0) of 'parse error' would give you your answer. Not to mention two others in the first 5.


I realize I sound condescending, but the best thing for you is just to start reading (have you seen the Scripting Tutorials?). I don't think you're a n00b, and I'm just trying to help you become better at scripting. (and I'm willing to help anytime)

~Trent
Title: Re: Parse errors up the chuffer. Inventory use woes.
Post by: Cluey on Fri 15/05/2009 20:49:39
Quote from: Trent R on Fri 15/05/2009 19:44:35
Quote from: Cluey on Fri 15/05/2009 18:39:29I've been without internet  for ages in my house, I've been poring over the manual for days and finding little, what should I search for?
Well, you can always just start reading, whether straight through or jumping through 'See Also' links.


For ActiveInventory, you can search 'inv' in the Index and the second item that pops up is 'Inventory Item events'. It says:
Quote from: ManualYou can use the player.ActiveInventory property to distinguish which item they used.
Which links directly to the ActiveInventory property.

Quote from: Cluey on Fri 15/05/2009 18:39:29The page I found on the subject had one = mark.
I take it you mean the Example on the ActiveInventory entry? Well, if you read what it says,
Quote from: ManualGets/sets the character's current active inventory item. Setting it will update the mouse cursor if appropriate.
Quote from: Manualwill make the inventory item iKey active
Both will tell you that the you can set the ActiveInventory, not just getting it (which is its most common usage). Combine that with basic scripting knowledge (look up Operators if you don't know) and you'll know that you use = for setting (and a semi colon) and == for checking (combined with brackets). This is the reason we don't like script kiddies on the forums that say "Give me teh code!!! Dont point me to a supid manual entry, or RTFM!!" because they don't understand the code that's give to them.

Also, if you had run a forum search, the first result (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37137.0) of 'parse error' would give you your answer. Not to mention two others in the first 5.


I realize I sound condescending, but the best thing for you is just to start reading (have you seen the Scripting Tutorials?). I don't think you're a n00b, and I'm just trying to help you become better at scripting. (and I'm willing to help anytime)

~Trent

Yeah, appreciated. I didn't know the difference between the two. A few days without internet made me forget my internet protocol (the manners one, not the address one).

I'm not a n00b to these forums (04 I think I joined, spend most of my time in the art places), I am a complete n00b to scripting, and I've got loads of my own code written fine, but when I hit on a tiny error I go mad.
Title: Re: Parse errors up the chuffer. Inventory use woes.
Post by: Cluey on Sun 17/05/2009 22:16:16
Double post to bump (hey it's less arsy than starting a new thread).

So now I'm getting the ol' "unexpected eof" error. I know the problem lies within this script as when I remove it it's fine:

    if(player.ActiveInventory == iDIY)
    {
    player.Say("Hows this for you?");
    cDan.Say("Hmm, they've spelt 'wrench' wrong on the first page");
    player.Say("So they have...");
    cDan.Say("You should be ok with this though, I had a look while you were in your office");
    player.Say("What do I need to do?");
    cDan.Say("The wire thingy in the control box is knackered");
    cDan.Say("See Chapter XII on that");
    player.Say("So I need to replace it?");
    cDan.Say("Just re-jiggery-thinging it should do, you'll need these tools");
    cDan.Say("Basically, you just need to screw the control box back onto the wall after reconnecting the wire");
    player.Say("Ah, I see, thanks Danny...);
    player.say("I think");
    player.AddInventory(iTools);
    player.LoseInventory(iDIY);
    }


I know they come from when you're missing a close bracket, but I'm pretty sure I've got them all. And I remember this lil' bit here worked before I added the active inventory bit mentioned above, so who knows.

Apart from you guys.

That's why I'm asking you.
Title: Re: Parse errors up the chuffer. Inventory use woes.
Post by: Trent R on Sun 17/05/2009 22:26:48
I saw it immediately, but pasted it into AGS to check.
The line is the 4th from the bottom:  player.Say("Ah, I see, thanks Danny...");


Two tricks to help you find missing braces and missing apostrophes.

1) When next to one brace (either '(', '[' or '{' ) Ctrl-B colors the opposite brace yellow. If there is no match, it colors it red.

2) Strings are colored red/maroon by the AGS editior when inbetween apostophes, but the line above is read if you look at the far away (but it's also easy to miss, so I totally understand your mistake. Has happened to me too)


[Edit]: Also noticed (when I tried to compile your script) that the next line after pops up an error becuse .say is lowercase. Capitalize it and it'll be fine (and since it's below your eof error, it didn't pop up before).


~Trent
Title: Re: Parse errors up the chuffer. Inventory use woes.
Post by: Cluey on Sun 17/05/2009 22:36:15
Quote from: Trent R on Sun 17/05/2009 22:26:48
[All that stuff he said]

Thanks alot, I feel like a bit of a dummy, but that's certainly a handy tip for finding the buggers.