Sorry if I'm going to clog up the forums today :-[
I cannot figure why the following gives me an error:
if (iInvHat1.GetProperty("IsHat"))
Error (line 43): Unexpected 'int'
IsHat is the Boolean property in the properties pane and set to true, so why not an integer??
GetProperty always returns integer. "Boolean" is just a way to set them up in the editor.
I forgot if AGS script can automatically convert integers too boolean expression... maybe it actually can? Or maybe it cannot in some cases.
Anyway, to check property in a boolean way you can do this:
if (iInvHat1.GetProperty("IsHat") != 0) // this means "is true"
{
}
if (iInvHat1.GetProperty("IsHat") == 0) // this means "is false"
{
}
thanks for our help CW
I added brackets and it seem to fix it.. was more to do with line 44 I guess.
InventoryItem *itemToSwap = player.ActiveInventory;
if (itemToSwap.GetProperty("isGlasses"))
{
glasV = itemToSwap.GetProperty("InvenView");
}
this does not work:
InventoryItem *itemToSwap = player.ActiveInventory;
if (itemToSwap.GetProperty("isGlasses"))
int glasV = itemToSwap.GetProperty("InvenView");
Looks like a script compiler bug. But if it worked properly, that variable would exist only for that one line, which won't make much sense.
yes your right. I had to declare it at the top of the function for it to work.