Parse errors up the chuffer. Inventory use woes.

Started by Cluey, Fri 15/05/2009 13:29:31

Previous topic - Next topic

Cluey

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.
Aramore
My webcomic.

Hudders

You need another = sign and to get rid of the semicolon on the end.

Code: ags

if (player.activeinventory == iBook)

Intense Degree

I love the name of this thread, it reads like a really weird cryptic crossword clue! :)

Trent R

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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Cluey

#4
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.
Aramore
My webcomic.

Trent R

#5
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 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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Cluey

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 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.
Aramore
My webcomic.

Cluey

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:

Code: ags
    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.
Aramore
My webcomic.

Trent R

#8
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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Cluey

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.
Aramore
My webcomic.

SMF spam blocked by CleanTalk