Help Combining

Started by COMMANDOS2, Mon 31/10/2022 06:16:32

Previous topic - Next topic

COMMANDOS2

Hello, i need so much help, please, i'm burning my brain trying to discover how :confused:  but i can't
i'm making my first game in the latest version of AGS and i got some problems combining items each other in the inventory, here is my work:

Spoiler
function iVault_UseInv()
{
        if (player.ActiveInventory == iKeys)
        player.LoseInventory(iVault);
        player.AddInventory(iVault1open);
        player.AddInventory(iLotofcash);
        cRoger.Say("YEAH! I'M RICH NOW!");
}
[close]
Code: ags
function iVault_UseInv()
{
        if (player.ActiveInventory == iKeys)
        player.LoseInventory(iVault);
        player.AddInventory(iVault1open);
        player.AddInventory(iLotofcash);
        cRoger.Say("YEAH! I'M RICH NOW!"); 
}



But here is the problem. :~(
if i pick another item (like a "iWallet"), i can use it on the iVault to open it too, i'm sorry if this is not the thread, but i need some help to make this work, Thanks!

Nahuel

#1
Hey @COMMANDOS2 you are totally forgetting the { }

Code: ags
function iVault_UseInv()
{
        if (player.ActiveInventory == iKeys)
        {
          player.LoseInventory(iVault);
          player.AddInventory(iVault1open);
          player.AddInventory(iLotofcash);
          cRoger.Say("YEAH! I'M RICH NOW!"); 
        }
}

[EDIT]
You can also read https://adventuregamestudio.github.io/ags-manual/ScriptingTutorial.html that is an excellent source.
Life isn't a game. Let's develop a life-like-game.

COMMANDOS2

Quote from: Nahuel on Mon 31/10/2022 06:34:36Hey @COMMANDOS2 you are totally forgetting the { }

Code: ags
function iVault_UseInv()
{
        if (player.ActiveInventory == iKeys)
        {
          player.LoseInventory(iVault);
          player.AddInventory(iVault1open);
          player.AddInventory(iLotofcash);
          cRoger.Say("YEAH! I'M RICH NOW!"); 
        }
}


THIS WORK!
now how can i do for add an "else" like if i'm using another item, "cRoger.Say" "nope, this doesn't wotk"?
i'm so grateful with your help, that i'm gonna cry, really thanks!!

Nahuel

Simply you add the else with { }

Code: ags
 function iVault_UseInv()
{
        if (player.ActiveInventory == iKeys)
        {
          player.LoseInventory(iVault);
          player.AddInventory(iVault1open);
          player.AddInventory(iLotofcash);
          cRoger.Say("YEAH! I'M RICH NOW!"); 
        }
        else
        {
          // the rest
        }
}
Life isn't a game. Let's develop a life-like-game.


SMF spam blocked by CleanTalk