msmalik681 said:
Sorry but your solution is the same as mine but with a extra step. If you can already get the current branch from the engine why store it in a global variable ?
Allow me to disagree with you.
No, they aren't the same. Your solution takes the current "branch", while mine identifies the current stage.
See this:
branch branch_mountains_3
z 210 300 0
file data/levels/mountains/st03.txt
z 210 300 0
file data/levels/mountains/st04.txt
z 210 300 0
file data/levels/mountains/st05.txt
Using your solution, it will return "branch_mountains_3" in all 3 stages, unless you set a branch for each stage (which IS a extra step).
There is a
stagenumber in openbor but, as the manual explains, it can get inconsistent to real progress.
This is how I use:
My version uses a levelscript (or you can paste as a spawnscript of a empty entity)
Code:
@script
void main()
{
void stageName;
if (!stageName){
setglobalvar("stageName","Sky Stage");
}
}
@end_script
So, when I want to check for a stage name, i just paste this:
Code:
void stageName = getglobalvar("stageName");
if (stageName == "Sky Stage"){
*INSERT YOUR LOGIC HERE*
}
And just to avoid issues, I free the globalvar in
endlevel.c (and I duplicate it into "ondestroy" at
updated.c
Code:
void main()
{
setglobalvar("stageName", NULL());
}
With my method, I have far more control and flexibility. Since I can even change the stage name on the fly.
In programming, it does not matter if a method uses more steps (pure and simple talking), it matters their effectiveness. Some solutions may use more steps but work better.