Hi Forumers!
(First, Im from Argentina, sorry for my "English" xD)
Im having trouble with my AGS project, especially with that function (c.Ego.ActiveInventory). Here is the principal code:
function Pato_UseInv()
{
if (cEgo.ActiveInventory == iPlata)
Display("Mmg.. si tenias unos pesos mas hablabamos. PERO NO");
else if (cEgo.ActiveInventory == iEntrada)
Display("Pasa pibe ya empieza");
cEgo.ChangeRoom(6, 112, 240);
}
Principally I have a problem, when I use "iPlata" on this Character, it says that ("Mmg.. bla bla"), but it also Changes the room!
I cant explain me very good, the function of any object is always the same!
I dont know what's happening, and I will be pleased if anyone could help me..
(Sorry for my English again xD)
That's funny because that exact problem was addressed incidentally in the other thread :)
If you want to execute more than one command only after a condition is met, you have to group the commands together using a {} block:
function Pato_UseInv()
{
if (cEgo.ActiveInventory == iPlata)
Display("Mmg.. si tenias unos pesos mas hablabamos. PERO NO");
else if (cEgo.ActiveInventory == iEntrada) { // open the block
Display("Pasa pibe ya empieza");
cEgo.ChangeRoom(6, 112, 240);
} // close the block
}
I'd suggest to get used to indenting your code like I did from the start, saves loads of debugging time :)
Of course there doesn't have to be more than one command inside the block. Putting the curly brackets around a single command:
if (cEgo.ActiveInventory == iPlata) {
Display("Mmg.. si tenias unos pesos mas hablabamos. PERO NO");
}
will work fine.
It Works!
Thanks Man, I've thought that was something related to brackets xD..
Thanks very much Again, you're very kind!
You're welcome, and btw, your english is very good, better than some natives' ;)