Stats don't change accordingly to the settings

Hi everyone, I’m having a weird problem with my project’s code.

In the stats page, you can choose to go to another scene, then to another. Here you can use a “cheat” to increase a certain stat percentage. The cheat works as a consumable token, and you start the game with 10 of them.

The problem is that after consuming 1 cheat and adding points to the stat percentage, when you exit the stats page and then re-enter it, the tokens are refilled and the stat is gone back to its previous level. Trying to do it again and again, I’ve randomly been able to take down the tokens at 9, but when I do the same thing I’ve just done, it doesn’t go down at 8 —again. At this point, I really don’t know what I’m doing wrong.

This is the code:

*choice
    #Use 1 chip.
        You have ${frtok} remaining chip@{(frtok>1) s|}.
        
        Do you want to use 1 chip?
        *choice
            #What are these chips?
                Blah blah, mock test. This is an explanation of the game mechanics.
                               
                Do you want to use 1 chip?
                *choice
                    *selectable_if (Egg<95) #Yes, use 1 chip.           
                        *set frtok (frtok-1)

                        Thank you! 1 chip used! 
                        *set Egg +5

                        *choice
                            #Exit.
                                *goto_scene cheats
                    #Go back.
                        *goto top_scene. 
            *selectable_if (Egg<95) #Yes, use 1 chip.
                *set frtok (frtok-1)

                Thank you! 1 chip used! 
                *set Egg +5
                
                *choice
                    #Exit. 
                        *goto_scene cheat
            #Go back.
                *goto top_scene
    #Go back.
        *goto top_scene

You might try to use the cheat in the stats and then ingame press the next Button. Then the Tokens should be reduced. As far as I know changes in the stats menu only apply after the actual Page from which it was opened is ended with the next Button.

1 Like

Mmh, so if the player uses the token and then on the “thank you page” clicks on “Return to the game” on the top, instead than using the “Next” button, it deletes the last action anyway?

I see. So the easiest solution would be to just delete anything after the actual “use 1 chip”, right?

No. Any changes implemented on the stats page only take effect after you “turn” the page in-game., not on the stats page. I think your problem might be something else.

Where do you declare the token variable?


Also, why use this:

*choice
	#Exit.
		*goto_scene cheats

Instead of this:

*page_break Exit
*goto_scene cheats

In startup,
*create frtok 10.

That’s a stylistic choice, that page is supposed to look like an electronic device where you can navigate around, so it seemed weird to have a button. But I could do it anyway, I guess.

Ok, next question: where’s cheats? When you use *goto_scene you usually include the name of the scene and the label.

Another thing is that you can’t use goto to return to the story from the stats page.

Was that a typo?

I’m sorry, I didn’t notice your last comment!

No, it wasn’t a typo, it’s a page after stats page. It actually works as it should, but as you and @Kaelyn pointed out, you have to turn the page in-game for it to take effect. Thank you for your help!