[SOLVED] Using an item on multiple hotspots, not the other way around

Started by OrkischeHorde, Wed 30/08/2023 18:54:58

Previous topic - Next topic

OrkischeHorde

Hiya, Noob here ;)
I'm sure this question has been asked before, but I'm missing the search terms...

I have an item, a pair of scissors, and would like to display a standard message when it's used with most hotspots, like "This doesn't need a haircut" or "no running (through) with scissors".

I could use the "Use inventory on hotspot" function, but I'd have to do this for every hotspot, which I don't want to.

Is there an easier way to do this?

RootBound

Yes, by using the unhandled_event function in the global script. There's a code for "use inventory on hotspot" (see manual here: https://adventuregamestudio.github.io/ags-manual/Globalfunctions_Event.html#unhandled_event ). That will explain how to use it.

Then, within the unhandled_event function you put something like this:

Code: ags
if (what == 1 && type == 3){
  if(player.ActiveInventory == iScissors){
    player.Say("This doesn't need a haircut.");
  }
}

Then (if there is any other code in the hotspot's own useinv function in the room script, like if it DOES respond to other inventory objects), you call unhandled_event(1,3) under an else statement, after the code for the item that does work.

If there is no useinv function coded for the hotspot, unhandled_event gets called automatically.

J. They/them. Here are my most recent games:

OrkischeHorde

Thank you very much! Works like a charm (I had to solve some other problems first before I could continue with this one XD)

SMF spam blocked by CleanTalk