Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Switch statements with string case values
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#2
RE: Switch statements with string case values

ok, i was the OP in the other thread, and I think I know how to get it working. I'm not an expert when it comes to scripting, so I cannot separate the integers from the string but you could do this:
void func()
{
AddTimer("1" , 1.0f , "Timer);
AddTimer("2" , 2.0f , "Timer);
AddTimer("3" , 3.0f , "Timer);
}
void Timer(string &in asTimer)
{
int x = asTimer;
switch9(x){
case 1:
     // stuff
     break;
case 2:
     // stuff
     break;
case 3:
     // stuff
     break;
     }
}
you mght also be able to do this
AddTimer("T1" , 1.0f , "Timer");
AddTimer("T2" , 2.0f , "Timer");


void Timer(string &in asTimer)
{
int x = SubString(asTimer , 2 , 1);
switch(x){
   etc...
}

}
im not sure about the proper syntax fo SubString though.

edit: I've just reread youre original post, I'm not sure if the above will help you at all. I dont know much about return values myself


Another Edit: I think I know the problem in your original code - you haven;'t got an if statement for if the asTimer is not any of the above, maybe
else return 0;
becausee maybe asTimer="" before the timer is called..

(This post was last modified: 07-22-2011, 11:06 AM by DRedshot.)
07-22-2011, 10:53 AM
Find


Messages In This Thread
RE: Switch statements with string case values - by DRedshot - 07-22-2011, 10:53 AM



Users browsing this thread: 1 Guest(s)