Help with Item Scripting

Started by teenage_musings, Tue 27/05/2008 09:03:06

Previous topic - Next topic

teenage_musings

I'm making a game, and in it I want the player after finding two items [example; battery and torch] to be able to "merge" them into one. I found it mentioned in the help/manual provided so I know it can be done, but I can't find the [scripting] instructions to do it.

Can anybody help? Please?

Khris

I assume you're using the default Sierra interface, right?

In the editor, select the first inv item, (*) click the lightning bolt icon to bring up the event linkage pane, then click on "Use inventory on this item", then on the ...-button.
Select the second item, then repeat from *.

You should end up at the end of the global script with two new functions:

Code: ags
function iKey_UseInv()
{

}

function iPoster_UseInv()
{

}


Now alter the code until it looks like this:

Code: ags
function comb_key_poster() {
  player.LoseInventory(iKey);
  player.LoseInventory(iPoster);
  player.AddInventory(iWrappedKey);
  player.Say("I've wrapped the poster around the key.");
}

function iKey_UseInv() {
  if (player.ActiveInventory == iPoster) comb_key_poster();
  else player.Say("That will achieve nothing.");
}

function iPoster_UseInv() {
  if (player.ActiveInventory == iKey) comb_key_poster();
  else player.Say("That will achieve nothing.");
}


Note how each function checks if the used item is the other one.

SMF spam blocked by CleanTalk