Solved score reset script question.

Question that is answered or resolved.

DD Tokki

Well-known member
Code:
set    Easy #=============================================================
branch        start
lives        7
credits        10
nosame         1 1
custfade        40
noshare         0
cansave        2

skipselect
select        data/select1.txt

z    174 274
file    data/level/stage00/L1/stage00a.txt
file    data/level/stage00/L1/stage00b.txt
next

This is my level setup.
Here, I wrote a script that returns the score to 0 each time it is reset using "branch start". I have a problem with going back to 0 every time I pass a stage. I'd like to resolve this.

bor - 0012.png Stage0-1

bor - 0013.png Stage0-2

Code:
void main()
{
    if(openborvariant("current_branch") == "start")
    {
    changeplayerproperty(0,"score",0);
    changeplayerproperty(1,"score",0);
    changeplayerproperty(2,"score",0);
    changeplayerproperty(3,"score",0);
    }
}

This is the script used.
 
The problem is that you declared a branch with "start" in your script. That way, it resets to 0 in every level you go to. To prevent this from happening, you can use that script, but without calling current branch by declaring levelscript in your first level of the stage.

Example:

stage00a.txt:
Code:
music        data/music/Miami.bor
Bossmusic       data/music/Boss.bor
background    data/bgs/1miami1/n01.png   
panel        data/bgs/1miami1/n01.png
frontpanel    data/bgs/1miami1/f01.png
order        aaaaaaaaaaaaaaaaaaaaaaaaaa
direction       right

levelscript data/scripts/reset.c

reset.c:

C:
void main()
{
    changeplayerproperty(0,"score",0);
    changeplayerproperty(1,"score",0);
    changeplayerproperty(2,"score",0);
    changeplayerproperty(3,"score",0);
}

For stage00b.txt, you don't need to put levelscript in it since you don't want your score to be reset.
 
The problem is that you declared a branch with "start" in your script. That way, it resets to 0 in every level you go to. To prevent this from happening, you can use that script, but without calling current branch by declaring levelscript in your first level of the stage.

Example:

stage00a.txt:
Code:
music        data/music/Miami.bor
Bossmusic       data/music/Boss.bor
background    data/bgs/1miami1/n01.png  
panel        data/bgs/1miami1/n01.png
frontpanel    data/bgs/1miami1/f01.png
order        aaaaaaaaaaaaaaaaaaaaaaaaaa
direction       right

levelscript data/scripts/reset.c

reset.c:

C:
void main()
{
    changeplayerproperty(0,"score",0);
    changeplayerproperty(1,"score",0);
    changeplayerproperty(2,"score",0);
    changeplayerproperty(3,"score",0);
}

For stage00b.txt, you don't need to put levelscript in it since you don't want your score to be reset.
thank you. The newly created structure works fine.
 
Back
Top Bottom