Hey guys, I recently posted in a thread that you could use strings in a case value for switch functions. I was wrong! I have begun to prefer switch functions because they're easy to read and easy to tweak.
Anyways, here's what I
thought would work:
AddTimer("timerone", 1, "TimerFunction");
AddTimer("timertwo", 2, "TimerFunction");
AddTimer("timerthree", 3, "TimerFunction");
void TimerFunction(string &in timer)
{
switch(timer) {
case timerone:
//cool stuff
break;
case timertwo:
//cool stuff
break;
case timerthree:
//cool stuff
break;
}
}
And here is what I'm currently trying (I get errors on recompiling the script)
void CaveBreathTimer(string &in timer)
{
switch(CaveBreathStep(timer)) {
case 1:
//stuff 1
break;
case 2:
//stuff 2
break;
case 3:
//stuff 3
break;
}
}
int CaveBreathStep(string &in stepname)
{
if(stepname == "cavebreath") return 1;
if(stepname == "screenshake") return 2;
if(stepname == "other") return 3;
}
And here's the error I get.
INFO : Compiling int CaveBreathStep(string&in)
ERR : Not all paths return a value
I'm trying to use a subroutine to return an integer which is used by the switch function to determine which case to execute, but the subroutine I wrote is giving me the above error. This way I can avoid using long-winded if statements. If this doesn't work I'll resort to sucking it up and neatly tabulating my if statements.
Also, is there any way to use straight-up use strings as case values in switch functions with AngelScript? I searched online and found a few vague threads that showed C++ code doing it.
I'm stepping into unknown territory, so if you could elaborate on this, please do. This is my first time trying to use return values
Thanks