Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Grizzly on Tue 21/11/2017 13:54:01

Title: How do I make a hotspot usable only after certain event is triggered?
Post by: Grizzly on Tue 21/11/2017 13:54:01
Hi, so I'm trying to figure this thing out. I have an object on my game, and the player has to use an inventory object on it so something happens. Then, after that happens, a hotspot that wasn't usable before needs to "unlock" somehow, how do I do that?
Title: Re: How do I make a hotspot usable only after certain event is triggered?
Post by: dayowlron on Tue 21/11/2017 14:32:18
Set up a global variable boolean lets say "Unlocked" and set it to false.
from the editor create a "Use Inventory On Object" event for the object you have.
in the event do something like:

    if (Player.ActiveInventory == oKey) {
        Unlocked = true;
    }

Then in the code for the hotspot only execute it if Unlocked is true:

    if (Unlocked) {
        .... do something
    }

Title: Re: How do I make a hotspot usable only after certain event is triggered?
Post by: Snarky on Tue 21/11/2017 15:52:55
... and if what you mean by "a hotspot that wasn't usable before" is that the hotspot didn't appear at all, you should create an "Enters room before fade-in" room event, and edit the function that gets created to something like this:

Code (ags) Select
function room_Load()
{
  hNameOfYourHotspot.Enabled = Unlocked;
}


(Just remember that if you can unlock the hotspot from within the room, you also need to update hNameOfYourHotspot.Enabled when you change the value of Unlocked there.)[/code]
Title: Re: How do I make a hotspot usable only after certain event is triggered?
Post by: KyriakosCH on Tue 21/11/2017 17:11:08
hm, can't one just use if (soandso) { hhotspopnumber.enabled=true; ?
Title: Re: How do I make a hotspot usable only after certain event is triggered?
Post by: Grizzly on Tue 21/11/2017 17:36:05
Quote from: dayowlron on Tue 21/11/2017 14:32:18
Set up a global variable boolean lets say "Unlocked" and set it to false.
from the editor create a "Use Inventory On Object" event for the object you have.
in the event do something like:

    if (Player.ActiveInventory == oKey) {
        Unlocked = true;
    }

Then in the code for the hotspot only execute it if Unlocked is true:

    if (Unlocked) {
        .... do something
    }

This was it!!! Thank you dayowlron!