Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Mon 22/10/2012 07:42:19

Title: SOLVED: using inventory on player script problem
Post by: Slasher on Mon 22/10/2012 07:42:19
I'm having some issues with using inventory on player.

Can someone please have a look for me and correct?

Will you assist?

It mainly appears to be when using crystal / chalk and using brownjar crops up a bit.

I apologise if somewhat messy

Meanwhile I will keep looking over it.

Script taken off now solved



Title: Re: using inventory on player script problem
Post by: Crimson Wizard on Mon 22/10/2012 08:47:24
Slasher, you could at least tell what's wrong is going on when you use this script....

But based on dialog inside the script I may make a guess that you have mistakes in conditions.
For example:

Code (ags) Select

if (cELF.ActiveInventory==ibluejar && cELF.Room==25 || cELF.Room==26 || cELF.Room==27)

This is probably supposed to deal this case when elf usues blue jar in rooms 25,26 and 27. But in fact it reads:
Quote
If active inventory is ibluejar AND room is 25
OR
room is 26
OR
room is 27
If you want this:
QuoteIf active inventory is ibluejar AND room is EITHER 25,26 or 27
You should take || operation in brackets:
Code (ags) Select

if (cELF.ActiveInventory==ibluejar && (cELF.Room==25 || cELF.Room==26 || cELF.Room==27) ) <-- notice extra brackets there around "rooms" part


This is because of order of operations: && operation is executed first, and || operations are executed after.

There are other instances of this mistake in your code.
Title: Re: using inventory on player script problem
Post by: Slasher on Mon 22/10/2012 08:59:57
I can't believe I did what I did  :-[

thank you so much Crimson

8-)