Hello,
someone could tell me what's wrong with this Switch statement/call function:
function bad_Inventory_use(String objcase)
{
switch(objcase)
{
case "cloud":
.... //do something
break;
case "sun":
...... //do something
break;
default:
..... //do something else
}
and I call it with:
function oCloud_UseInv()
{
bad_Inventory_use("cloud");
}
but it always execute the default case....I tried to put a Display("%s",objcase) in the default case
to check the value of objcase and it returns "cloud" as it should be.
According to the AGS release thread:
Quote- Strings do not work with switch/case script commands as intended. They were supposed to be compared by value, but are instead compared as pointers. This worked in some early BETA versions, but was broken at some point. This hopefully will be fixed in one of the future updates.
Thank you very much!
Yeah, that was an unfortunate oversight, but Gurok fixed this for future version (3.4.1). At the moment you should be using "if/else if" with strings.
Ok, not a problem at all.
Thanks again!