Scripting problems with making one item open one thing

Started by Ibrahim9, Tue 12/08/2008 22:02:18

Previous topic - Next topic

Ibrahim9

I kind of got in a bit of a mess when trying to make only ONE item open a chest. Can anyone help?
PS If this is too complicated and the moderators delete this, ill understand.

function igumkey_a;

  function oChest_UseInv()
  {
    if (player.ActiveInventory == igumkey)
    {
      player.LoseInventory(igumkey);
      player.Say("Great it's unlocked!");
      oChest.Graphic = 6;
      chestUnlocked = true;
    }
    else
    {
      player.Say("As you can see, it's locked and I need some sort of key");
  }
}
 
function oChest_Interact()
{
 
  if (!chestUnlocked)
  {
    player.Say("It's locked, and I can't reach inside.");
  }
  else
  {
    if (!chestEmpty)
    {
      player.Say("Now I have the camera.");
      player.AddInventory(icamera);
      chestEmpty = true;
      oChest.Visible = false;
    }
    else
    {
      player.Say("Nothing in that chest.");
    }
  }

}

Pumaman


Ibrahim9

Quote from: Pumaman on Tue 12/08/2008 22:11:03
What exactly is the problem?

well, i have an item named igumkey and I want it to open oChest, but i kind of screw of the scripting so that everytime i click the chest with the gumkey, nothing happens

Khris

Code: ags
bool chestUnlocked, chestEmpty;

function oChest_UseInv() {
  if (player.ActiveInventory == igumkey) {
    player.LoseInventory(igumkey);
    player.Say("Great it's unlocked!");
    oChest.Graphic = 6;
    chestUnlocked = true;
  }
  else player.Say("As you can see, it's locked and I need some sort of key");
}
 
function oChest_Interact() {
  if (!chestUnlocked) player.Say("It's locked, and I can't reach inside.");
  else {
    if (!chestEmpty) {
      player.Say("Now I have the camera.");
      player.AddInventory(icamera);
      chestEmpty = true;
      oChest.Visible = false;
    }
    else player.Say("Nothing in that chest.");
  }
}

And check that the function names are entered correctly in the chest's event pane.

SMF spam blocked by CleanTalk