Stat chart and screen/scene always changes when i check the stats

Hello,

i tried again to make choicescripts so i started to make a small story and some code to handle it.
But i have a problem what i cannot really understand. When i change to the stat screen, at first i see the proper stats. But when i change back, i see the original screen of the game and story is changed a little, and if i change back to the stats again, the statistics are randomly changed.

This happen only with a variable i usually change (hp stat), but between the screen switch nothing should be changed. I press no buttons, no fights happens, nothing, only the screen change.

Do you have any idea why this can be happen?
Thanks in advance.

Can you help us with some screenshot of it and some code?

As far as I know changes at the stat screen on reentering are usually caused because of a *rand variable that it’s rolled again once you get out of the stat screen and the program returns to the label running the *rand command again and thus changing the variable every time you come and go from there.

2 Likes

This makes sense. But then how can i store the values? I check the code and try to find out something. I also think maybe the scene became too complex with numerous gotos and i have to disassemble it into smaller scenes.

1 Like

You should make the game stops on a label without a *rand command.

Not ok:

*label 001
*rand randomize 1 3
*if randomize = 1
  text
*elseif randomize = 2
  text and more text
*else
  more text

OK:

*label 001
*rand randomize 1 3
*goto 002

*label 002
*if randomize = 1
  text
*elseif randomize = 2
  text and more text
*else
  more text

Or you can run the *rand on a separate file with gosub and return, I think it might work too though I haven’t tested that way.

1 Like

Thanks :relaxed: i will try.

1 Like

This also applies not only on *rand, but also to all forms of *set commands.

1 Like

I think @Loudbeat has it. When I use *rand in game, I *rand it early and make sure I have a *page_break or a *choice, *fake_choice, or some other break before I actually use the value:

*temp random_number 0
*rand random_number 1 100
*page_break
And now that random number is fixed, regardless of checking stats.  It's already been randomized, and now it's ${random_number}.  Ready for if statements of whatever else you want.

In one busy game I made, I had several variables for random numbers and I’d random the next one while checking the previous.

*rand random_number_1 1 100
Stuff happens
*page_break
And now I'd use ${random_number_1} for whatever, but also randomize the other variable for next time.
*rand random_number_2 1 100
*page_break
And now I'd use ${random_number_2} for whatever, and set up the next one, using the previous variable.
*rand_random_number_1 1 100
And keep alternating so I always have a random number ready, but it was randomized earlier, but not used, so the player can't see it until it's locked in place.