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!");
}
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!
Hey
@COMMANDOS2 you are totally forgetting the
{ }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.
Quote from: Nahuel on Mon 31/10/2022 06:34:36Hey @COMMANDOS2 you are totally forgetting the { }
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!!
Simply you add the else with { }
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
}
}
See also here:
https://adventuregamestudio.github.io/ags-manual/ScriptKeywords.html#if-else-statements