How to edit stats using a debug/developer menu?

when i load my txt files in the scenes folder, and run my game on the browser my question would be how can i edit my stats?
I mean not from the code, only to test some things of my game?
Thanks!

I’m not quite understanding what you want to do. You can’t edit your stats without coding it. Could you elaborate?

@sviyagin i mean that, I already wrote the stats and when I run the game I want to modify the stats inside the browser, is this possible?

Do you mean…

*set strength +10
*set streangh %+10

The only way to modify the stats is to code it somewhere. For the purpose of testing/playing around with your game, you could add a choice like

*label modify_stats
*fake_choice
  #Increase strength by X
    *set strength +x
  #Decrease strength by X
    *set strength -x
  #Etc
  #Proceed
    *goto proceed
*goto modify_stats

*label proceed
Yada yada

Because this is a fake choice (i.e. you don’t need a *goto), all of the options will go back to the modify_stats label except the #Proceed option. It would work best as a gosub routine that you can access through the stats screen

ETA: instead of *set, you could also do *input_number and then you can adjust the stats to whatever level you want in one go

5 Likes

To build on this idea, you could do:

*label modify_stats
*temp var ""
*temp value ""

*input_text var
*input_text value

*set {var} value
*return

You can check the value of any variable on the browser. Open the developer’s tool (usually: ctrl + shift + i), go to the console, and type this.stats.<variable name>. For example:

this.stats.dexterity

I’m not sure if you can alter the value from the console, though. Seems likely.

3 Likes

I would recommend doing what @sviyagin and @cup_half_empty suggested. It’s essentially creating a Debug Menu/Developer Menu that you disable/delete when your game is published (or keep it in as a fun little easter egg!)

I did this with my game as well.
*create debug false
*comment: If true, enables debug menu in Stats Screen

This isn’t uncommon at all. It’s why games like Counter-Strike and Minecraft have commands/cheats, they were coded in by the developers to help debug their game.

Writing sections of code that readers won’t access on publishing may sound like a waste of time to some, but if you ask me, it’s worth taking an hour to two to code in a debug menu when compared to the hours I spent fixing issues. It helps provide additional clarity to issues and really cut down the time it takes to fix them.

3 Likes

I have checked. If you’re running the game in the browser:

  1. Open the developer’s tools. All modern browsers have them. How to access may vary from browser to browser, but it is fairly easy to find out with a Google search.

  2. Go to the console:

  3. Type this.stats then the name of the variable.
    image

  4. This also allows you to change the value:
    image

BUT…!!!

  1. You can’t do this on the stats page. Once you return to the game, the engine will reload the page and set the previous value.
  2. You can’t do this and access the stats page right after for the same reason above.
  3. You have to set the value on the story page and proceed at least once, either by making a choice or pressing “Next”. Then the new value will be saved.
4 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.