Multiple actions with inventory items

Started by TheRoger, Mon 19/04/2010 20:33:14

Previous topic - Next topic

TheRoger

I'm stuck, Again...

I'm using Abstaubers 9 verb GUI and I'm working with inventory right now. I want to put two actions in one piece of script. But only one of them works (the one of them witch is on top). What I need to do to make this work?

Here's my try:

Code: ags
function icap_OtherClick()
{
  if (UsedAction(eGA_LookAt))
  {
    player.Say("A bottle cap.");
    player.Say("What can I possibly do with this?");
  }
  else if(UsedAction(eGA_UseInv)) {
    if (player.ActiveInventory == ihalfbottle) {   
      player.Say("I need to fill this bottle first.");
}}
    else if(UsedAction(eGA_UseInv)) {
    if (player.ActiveInventory == ifullbottle) {   
      player.Say("This will take a sec.");
      player.LoseInventory(ifullbottle);
      player.LoseInventory(icap);
      player.AddInventory(icappedbottle);
    }}
    else Unhandled(); 
}


Matti

This doesn't make much sense, the second else if will never be checked:

  else if(UsedAction(eGA_UseInv)) {}
  else if(UsedAction(eGA_UseInv)) {}


The code should look like this:

Code: ags

function icap_OtherClick()
{
  if (UsedAction(eGA_LookAt))
  {
    player.Say("A bottle cap.");
    player.Say("What can I possibly do with this?");
  }
  else if(UsedAction(eGA_UseInv)) {
    if (player.ActiveInventory == ihalfbottle) {   
      player.Say("I need to fill this bottle first.");
    }
    else if (player.ActiveInventory == ifullbottle) {   
      player.Say("This will take a sec.");
      player.LoseInventory(ifullbottle);
      player.LoseInventory(icap);
      player.AddInventory(icappedbottle);
    }
    else Unhandled(); 
  }

TheRoger


SMF spam blocked by CleanTalk