Author Topic: How to make a debug mode?  (Read 257 times)

MichaelNG789

  • Newbie
  • *
  • Posts: 13
    • View Profile
How to make a debug mode?
« on: June 21, 2018, 04:11:57 am »
I wanted to make a small debug mode in my quest. If you press a certain key, (in my case "m") you can press for example the number keys to get more hearts on the spot. I was thinking that I would use this in game_manager since I need the datatype "game" for "game_set_life(number)." I was trying to use a boolean with debug_mode being a variable and pressing "m" if debug_mode is true allows the extra commands, and the opposite as well to turn off debug mode, but it wasn't working for me. How could I do this?

Max

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: How to make a debug mode?
« Reply #1 on: June 21, 2018, 04:58:22 am »
Maybe post the code you have to make it easier to understand what you've done and where it isn't working. I also think the Solarus team has a debug mode code in some of their games, maybe look through their GitHub.

I think, even if you're not using game manager, the code sol.get_game = game might work to give you that data. But the main idea is to use game:on_key_pressed(key), and then if key == m, do your code. It might be quicker to code one key that adds a heart, then one key that subtracts a heart, rather than using the number keys. Plus then you could go above 9 hearts this way.

Neovyse

  • Administrator
  • Full Member
  • *****
  • Posts: 130
    • View Profile
Re: How to make a debug mode?
« Reply #2 on: June 25, 2018, 10:11:23 pm »
We did it with a simple file (empty) called debug, in the saves folder. We check if the file is present. You can look in our games like Mercuris Chess for more info.