How do I make a hotspot usable only after certain event is triggered?

Started by Grizzly, Tue 21/11/2017 13:54:01

Previous topic - Next topic

Grizzly

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?

dayowlron

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:
Code: ags

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

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

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

Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

Snarky

... 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
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]

KyriakosCH

hm, can't one just use if (soandso) { hhotspopnumber.enabled=true; ?
This is the Way - A dark allegory. My Twitter!  My Youtube!

Grizzly

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:
Code: ags

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

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

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

This was it!!! Thank you dayowlron!

SMF spam blocked by CleanTalk