Flow Of Program

Okay guys this is even weirder than the lacking abilities to manipulate text in
a FULLY TEXT-BASED environtment, it’s about the damned “Show Stats” button.

first, I made a “startup” like this:

the idea on startup is just for declaring variables, then head to “intro”

to print the value of numc, which is “1”, everything looks fine, then I hit “Show Stats” button

inside, I put a code just like that to add numc by 1 everytime I hit the “Show Stats” button, I even debug it just to make sure it’s added, now numc has the value of “2”

so I hit “Return to the Game” button, but the stepping brings me back to startup.txt which is weird, it has to take me back to “intro”, where I printed the value of numc, it should return to the last part where I left for “Show Stats” button.

I don’t get this, the program has reached the finish in intro.txt and printed something, but re-read everything back from startup if I return from “Show Stats” button, I feel this is wrong, or is there something that I forgot to write somewhere?

I just want to add numc by 1 everytime I hit “Show Stats” button, and the printed value follow it up, but now the value returns to “1” because it re-read the startup when I return to the game.

please help, thank you.

I don’t think adding inside of the stats file actually does anything. AFAIK what you seem to be trying to do isn’t possible. I’m definitely not an expert on Choicescript though.

1 Like

okay guys I think I found the curse of “Show Stats” button

now I add a label to it, called go, and a choice to add numc by 1 and reprint it again.

After 5 times, i got the value of “5”, then hit “Show Stats” button, hit “Return to the game”, and it’s still “5”.

okay, so it doesnt re-read everything back from startup.txt, but anything happens in choicescript_stats.txt will not permanently modify variables, even if it shows modification on the debug screen.

so the last question is, how do I shot down that cursed button? I don’t want that button to show anymore, forever.

I’m planning to create a menu where players can increase stats, change equipments, so on and so on, a standard RPG-esque features, but now I can’t build it on choicescript_stats.txt because it’s a cursed ground.

In order for choicescript_stats to a)change the variable value and b) reflect changes in the game, you’d need to move to the next screen. Either via a choice or a page_break. Like you found out by adding fake_choice in your example.

And no, you cannot remove “show stats” button if you intend to publish your game.

1 Like

Well, Creatures Such As We has no stats screen and is published. So it’s definitely possible. Though it is a CoG game and not HG.

It is possible. But that requires modification to the choicescript and isn’t something that is solely up to authors. My advice would be for now to completely ignore the stats button and when you publish to ask HG to remove it from final product.

1 Like

Correct. When you enter the stats screen your game state is “saved” and “restored” on closure. The value is modified, but only within the context of the stats screen.

As I recall it behaves Iike this because on some platforms the stats screen is always visible (side by side with the game view).

There is a command called “redirect_scene” that attempts to work around this, but it requires you to specify a specific place to return to, which isn’t always convenient.

4 Likes

Trying to think of ways to use redirect scene. Maybe the option only appears in stats when you’re at a hub world, so you don’t exit out of a scene in progress. Or after every single page break you include a label and a stat that references the label, and then the redirect scene references the stat to get back to the label. Or maybe it comes with a warning like “this will restart your current scene, proceed?”

the safest approach should be leaving the “Show Stats” button just to show something, not for modifying.

Adding “Redirect Scene” feature will only makes thing more confusing because “Return to the Game” button still exists.

Moreover, its usage won’t be effective, let’s say with a label that contain more than one page, if I try to “redirect” from stats screen, it will re-read all over from the beginning of label, I haven’t tried this but I’m quite sure it need high precision to redirect properly.

thank you for all the replies, now I have a clear usage of stats screen, might as well request a thread closure to the mods @moderators

1 Like