Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Thanyx on Sat 24/06/2017 11:38:05

Title: Take Item Only Once From Hotspot [SOLVED]
Post by: Thanyx on Sat 24/06/2017 11:38:05
Hello,

I am sorry, for this trivial script question, but I am really lost.

I have a hotspot (Locker) and if player interacts with the Locker, he will acquire an item (Pills).

My question is:
How do I code that if the player ever clicked on the hotspot, he will not be able to take pills twice.
Because I tried to code classic "DoOnceOnly" script so if player HasInventory(iPill), then he will say "I already took them".

The problem is, that if player ever gets rid of the Pills, suddenly, player is able to take the Pills from the Locker again.

Any ideas?

Title: Re: Take Item Only Once From Hotspot
Post by: Cassiebsg on Sat 24/06/2017 11:43:41
Well, then I would say you used the DoOnceOnly wrongly.

Try this:

if (Game.DoOnceOnly("Taking pills from locker"))
{
    player.AddInventory(iPill); // This action will only be done once
}
else player.Say("There's nothing else interesting in the locker."); // Every other time the player interacts with the locker he will say this.
Title: Re: Take Item Only Once From Hotspot
Post by: Thanyx on Sat 24/06/2017 11:55:28
I am just stupid and used DoOnceOnly really wrongly.

It is so obvious now :) Thank you very much for your help Cassiebsg!