[SOLVED] Multiple Codes Keypad

Started by GameMaker_95, Wed 03/01/2018 06:27:14

Previous topic - Next topic

GameMaker_95

EDIT: I'll leave the original post here but sorry I worked out a solution after posting it. I apologize as I don't know how to delete the post but the code may help others.




Hello,

So I've started working on my game again after a break due to personal reasons. Before the break I had help with an elevator keypad set up but couldn't find the post with the person who helped me, so, sorry about that.
I've since realized I'd like to use multiple codes and not just one, but I cannot. It would probably be easier to call up a dialog tree to choose the floor I'd like to travel to and may end up doing that, but I
was wondering if I could get some help to make it work with multiple codes and not just what I have here which works with 9 hotspots each corresponding to a number. The main problem is using the same hotspot/number in multiple codes. Any help would be greatly appreciated.

Thank you.

Code: ags

int sequence=0;

function hHotspot9_Interact()
{
 if (sequence == 0) sequence++;
   else sequence = 0; // wrong combination, so start again
}

function hHotspot3_Interact()
{
   if (sequence == 1) sequence++;
   else sequence = 0; // wrong combination, so start again

}

function hHotspot6_Interact()
{
   if (sequence == 2) sequence++;
   else sequence = 0; // wrong combination, so start again
}

function hHotspot2_Interact()
{
  if (sequence == 3) { // correct combination so
      player.ChangeRoom(6, 231, 135); // give player the ice cream
   }
   else sequence = 0; // wrong combination, so start again
}

function hHotspot10_Interact()
{
  player.ChangeRoom(1, 161, 97);
}

SMF spam blocked by CleanTalk