Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: phillipPbor on Tue 10/11/2015 23:05:37

Title: find idems
Post by: phillipPbor on Tue 10/11/2015 23:05:37
i need to know something.
if you examine the bed, you go there and finds what is under the bed, you got the key.
if you check again, nothing.

but what do you all think it dose?
Title: Re: find idems
Post by: Mandle on Tue 10/11/2015 23:32:26
Are you asking how to make it so that the key item in your game can only be found once?
Title: Re: find idems
Post by: phillipPbor on Tue 10/11/2015 23:38:56
i know how inventory item works and how to use them. what i don't know was how to make hotspot react? after click on it once.
Title: Re: find idems
Post by: Mandle on Tue 10/11/2015 23:49:17
Ah, gotcha...I have no time to explain right now. Can somebody field this one. Cheers!
Title: Re: find idems
Post by: Khris on Wed 11/11/2015 00:40:03
Try this:
function hBed_Interact() {
  // walk over, look at it, etc
  if (Game.DoOnceOnly("find key under bed")) {
    Display("You search under the bed and find a key.");
    player.AddInventory(iKey);
  }
  else {
    Display("There's nothing else to be found.");
  }
}


The text you use for "find key under bed" doesn't really matter, as long as you don't reuse it in another Game.DoOnceOnly() command elsewhere.
Title: Re: find idems
Post by: Zack Casey on Wed 11/11/2015 07:23:44
The text you use for "find key under bed" doesn't really matter, as long as you don't reuse it in another Game.DoOnceOnly() command elsewhere.
[/quote]

The power of if-else (and soon switch) statements can't be underestimated. These can help you keep your game persistent, dynamic, and even help you avoid crashes.

Edited by mod: Removed unnecessary quote.