Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: TheRoger on Mon 19/04/2010 20:33:14

Title: Multiple actions with inventory items
Post by: TheRoger on Mon 19/04/2010 20:33:14
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:

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();
}

Title: Re: Multiple actions with inventory items
Post by: Matti on Mon 19/04/2010 21:13:15
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:


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();
  }
Title: Re: Multiple actions with inventory items
Post by: TheRoger on Tue 20/04/2010 06:04:50
Thank you, I think I got it now.