Author Topic: Parse errors up the chuffer. Inventory use woes.  (Read 457 times)  Share 

Cluey

  • Jiggleh!
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
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

  • Excuse me while I waffle
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with voice acting
    •  
Re: Parse errors up the chuffer. Inventory use woes.
« Reply #1 on: 15 May 2009, 13:36 »
You need another = sign and to get rid of the semicolon on the end.

[code]
if (player.activeinventory == iBook)
[/code]

Re: Parse errors up the chuffer. Inventory use woes.
« Reply #2 on: 15 May 2009, 14:06 »
I love the name of this thread, it reads like a really weird cryptic crossword clue! :)

Trent R

  • "I am the weapon" -Richard Cypher
    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
Re: Parse errors up the chuffer. Inventory use woes.
« Reply #3 on: 15 May 2009, 17:39 »
There 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

  • Jiggleh!
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Re: Parse errors up the chuffer. Inventory use woes.
« Reply #4 on: 15 May 2009, 18:39 »
There 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.
« Last Edit: 15 May 2009, 19:19 by Cluey »
Aramore
My webcomic.

Trent R

  • "I am the weapon" -Richard Cypher
    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
Re: Parse errors up the chuffer. Inventory use woes.
« Reply #5 on: 15 May 2009, 19:44 »
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?
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: Manual
You can use the player.ActiveInventory property to distinguish which item they used.
Which links directly to the ActiveInventory property.

The 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: Manual
Gets/sets the character's current active inventory item. Setting it will update the mouse cursor if appropriate.
Quote from: Manual
will 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
« Last Edit: 15 May 2009, 19:46 by Trent R »
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

  • Jiggleh!
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Re: Parse errors up the chuffer. Inventory use woes.
« Reply #6 on: 15 May 2009, 20:49 »
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?
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: Manual
You can use the player.ActiveInventory property to distinguish which item they used.
Which links directly to the ActiveInventory property.

The 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: Manual
Gets/sets the character's current active inventory item. Setting it will update the mouse cursor if appropriate.
Quote from: Manual
will 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

  • Jiggleh!
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Re: Parse errors up the chuffer. Inventory use woes.
« Reply #7 on: 17 May 2009, 22: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:

[code]    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);
    }[/code]

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

  • "I am the weapon" -Richard Cypher
    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
Re: Parse errors up the chuffer. Inventory use woes.
« Reply #8 on: 17 May 2009, 22:26 »
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
« Last Edit: 17 May 2009, 22:37 by Trent R »
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

  • Jiggleh!
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Re: Parse errors up the chuffer. Inventory use woes.
« Reply #9 on: 17 May 2009, 22:36 »
[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.