Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: saanb on Sat 07/06/2003 09:18:28

Title: conditional interaction
Post by: saanb on Sat 07/06/2003 09:18:28
how do i make so that a player can't use an object unless he has a reason like i don't want the player to get an inventory object when he interacts with it until he has looked at or interacted with another object. i know about the if he has a certain inventory item thing but he's not going to have the inventory item, he just would've interacted with it. thanks for helping.
Title: Re:conditional interaction
Post by: miguel on Sat 07/06/2003 11:52:04
try this:

//on top of your room script define a variable
int INVPICKED = 5;
//
//select Objects from the editor
//chose Interact Object
//chose RunScript

  if (INVPICKED = 5) {AddInventory(x); ObjectOff(y);
else Display "I don't need it now";
}

then when you want your character to pick it up just give INVPICKED the value 5; if you set this variable a value outside this room then you'll have to import it, check the manual for that
I hope it helps cause Im starting out too
Title: Re:conditional interaction
Post by: Timosity on Sat 07/06/2003 12:15:30
I just noticed a couple of errors miguel,
don't initially set int INVPICKED to 5 or it will already be 5 which you don't want
and this line needs another "=" sign "if (INVPICKED == 5) "
otherwise all it will do is set INVPICKED to 5

this is what it should look like

//on top of your room script define a variable
int INVPICKED ;
//
//select Objects from the editor
//chose Interact Object
//chose RunScript

  if (INVPICKED == 5) {
AddInventory(x); ObjectOff(y);
}
else {
Display "I don't need it now";
}

if it happens outside the screen you could use a globalint

eg

In the global script after this line "function game_start() {"

SetGlobalInt(10,0);

Then in the room

  if (GetGlobalInt(10) == 5) {
AddInventory(x); ObjectOff(y);
}
else {
Display "I don't need it now";
}


When you look at object or do something in another room to trigger what you want

SetGlobalInt(10,5);
Title: Re:conditional interaction
Post by: miguel on Sat 07/06/2003 13:15:40
much cleaner indeed, thanks