Gosub and looking at the stat screen question

Just a quick question.

I am using a stat cap gosub that looks something like this:

*label xcheck
*if x > 100
  *set x 100
*if x < 0
  *set x 0

My question is this:

What happens if I am doing this in game:

Blablablah text text.
*set x + 10
*gosub xcheck

Blablablah more text.

and someone checks the stat screen or reloads the page? Will it add x + 10 again every time someone reloads the page? Or is this a safe use?

When the player reads the actual story page, the code resolves and the stats are capped. The stats screen will print the capped stat. The loop is closed and your stats will always capped, regardless.

So, ye, fairly safe to use. But I’m on mobile currently; best to test it in real env.


Cool, thanks. I thought that was the case, but I hadn’t played around with gosubs like that before so I got nervous.


From my experience, the only command that gets evaluated every time the player enters the page is random.

I have developed the habit of moving any code to the top of the page and encapsulating it between *page_breaks. CS ignores consecutive page breaks if there’s no text printed to the screen, but behind the curtain it still considers them to be on different pages.

This way, “text pages” have no code and “code pages” have no text. It ensures CS will never hit any code line more than once.


They all get re-run/evaluated, it’s just that only *rand is going to have a chance of evaluating differently.

Interesting double page_break tip though.


I knew that it ignores consecutive page breaks, but I never thought of exploiting that to fix the *rand issue! That’s really clever and should be integrated into common practice.

1 Like