Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: beaver on Thu 13/05/2004 02:47:56

Title: an object in a drawer
Post by: beaver on Thu 13/05/2004 02:47:56
Hi, I have made the drawer, i have made the item for inside it.
I have a hotspot that when clicked brings up an object which is a view of the drawer open. the hotspot also brings up the item that is inside the drawer using the switch item back on command. the only problem is that when the item is taken and the drawer is closed, the item reapears once the drawer is opened again.
Is there a command to switch the item off completly? or am i simply doing it wrong?

thanks for any help.
Title: Re: an object in a drawer
Post by: Darth Mandarb on Thu 13/05/2004 03:59:29
if (character[GetPlayerCharacter()].inv[X] > 0) { [color=00AA00]// checks to see if it's in inventory[/color]
DisplayMessage("The drawer is empty.");
else {
ObjectOn(0); [color=00AA00]// drawer open picture (whatever # it is)[/color]
ObjectOn(1); [color=00AA00]// object in drawer (whatever # it is)[/color]
}

.inv[X] = the object from the game's inventory (the object in the drawer)

This will check to see if you have the object (inv[X]) in your inventory.Ã,  If you do have the object (meaning you've already taken it from the drawer) it'll just say "the drawer is empty".Ã,  However, if you don't have the object, it'll go ahead and perform what you've already scripted.

Does this make sense?

You could also make the drawer open (instead of saying "it's empty") but not turn on the inventory object if you've already got it.
Title: Re: an object in a drawer
Post by: beaver on Thu 13/05/2004 04:25:50
i tried the one u did, and it said error string with non string or something on the line with the message in.
Then i tried it the way i want it and it said parse error at else
here is the script

if (character[GetPlayerCharacter()].inv[4] > 0) {
ObjectOn(4);
else {
ObjectOn(4);
ObjectOn(1);
}
Title: Re: an object in a drawer
Post by: Gilbert on Thu 13/05/2004 04:33:20
if (character[GetPlayerCharacter()].inv[4] > 0) {
ObjectOn(4);
} else {
ObjectOn(4);
ObjectOn(1);
}
Title: Re: an object in a drawer
Post by: beaver on Thu 13/05/2004 04:36:47
ah thanks, i just managed to get it to work but i had to make it run 2 scripts, thats alot better.

thanks.
Title: Re: an object in a drawer
Post by: Darth Mandarb on Thu 13/05/2004 05:55:28
Damn brackets!!

Sorry 'bout that.

~ d
Title: Re: an object in a drawer
Post by: TerranRich on Thu 13/05/2004 15:33:59
I'd like to take this opportunity to unveil the debut of a new Beginners' image:

(http://www.rain-day.com/harbinger/misc/braces.jpg)

This is only a light tease, don't take it personally. :) It happens to ALL of us! :D
Title: Re: an object in a drawer
Post by: Gilbert on Fri 14/05/2004 02:19:05
hehe yeah, happened to me too. I once spent nearly an hour to track down my mistakes on braces.