Solarus-Games English Forum

Solarus => Development => Topic started by: MichaelNG789 on June 21, 2018, 04:11:57 AM

Title: How to make a debug mode?
Post by: MichaelNG789 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?
Title: Re: How to make a debug mode?
Post by: Max 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.
Title: Re: How to make a debug mode?
Post by: oclero 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.