O Ilusionista
Captain 100K
Watching the discussion on another topic, I decided to share a solution I made to help me to indentify which stage the player is right now.
There are two other methods to achive something like this, but both has issues:
My solution uses a globalvar and check to achive this
It uses a levelscript (or you can paste as a spawnscript of a empty entity)
So, when I want to check for a stage name, i just paste this:
And just to avoid issues, I free the globalvar in endlevel.c
And I duplicate it into "ondestroy" at updated.c
I tested and it works (I use it on my Avengers mod).
There are two other methods to achive something like this, but both has issues:
- Getting "current_branch" > only gets the current branch, not the current stage. If you have a branch with 4 stages, all the stages will return the same value, since they are part of the same branch
- Getting "stagenumber" > as the manual explains, it can get inconsistent to real progress, because it only count the number of NEXTs used.
My solution uses a globalvar and check to achive this
It uses a levelscript (or you can paste as a spawnscript of a empty entity)
Code:
@script
void main()
{
void stageName;
if (!stageName){
setglobalvar("stageName","My Stage"); // Put your stage name here. It's CASE SENSITIVE.
}
}
@end_script
So, when I want to check for a stage name, i just paste this:
Code:
void stageName = getglobalvar("stageName");
if (stageName == "My Stage"){
*INSERT YOUR LOGIC HERE*
}
And just to avoid issues, I free the globalvar in endlevel.c
Code:
void main()
{
setglobalvar("stageName", NULL());
}
And I duplicate it into "ondestroy" at updated.c
Code:
void ondestroy()
{
if(getglobalvar("stageName"))
{
//free(getglobalvar("stageName"));
setglobalvar("stageName", NULL());
}
}
I tested and it works (I use it on my Avengers mod).