How to debug a specific collection/stage/game configuration?

Hello folks,
If I was to try making a pretty big game with Defold how would I proceed to launch debug not at the beginning of the game ? For example, to launch a specific level/stage, to launch with a specific inventory, or to launch after some specific random results.

Is it a better way than changing the main collection in project configuration ?

Thanks

A way is to add some code like:

if some_thing then 
  print " break point line"
end

It solely depends on what you want to do.
Such mechanics take multiple iterations until you have something you like.

  • Setting the level collection as the bootstrap collection is one way.

  • Having a debug button in a corner of the screen is another, allowing you to access a debug menu where you can send the appropriate messages (load level, assign health, deal damage, spawn enemies etc)

  • Also, once could use the config system if you’re launching from command line, using the --config=... option to configure the game.

2 Likes

sorry, I don’t see how this is supposed to answer my question
I wonder how to launch debugging in some gamestate, not how to pause it in some gamestate

If you don’t want to launch the game with debugging and then stop on a break point you can attach to your running game instead; I have not done the latter, you have not been able to work this out from the manual, is it not helpful?

Oh sorry I get why my post wasn’t clear :
I meant “run the game in debugging mode with a specific game configuration”, for example if you code a Mario and you want to launch the game in the middle of some stage with a specific Mario transformation and a specific coins number.

I think Mathias accurately answered your question. Adding a debug menu with “cheat” options is definitely a good solution. You can check if the game is running in debug mode using sys.get_engine_info().is_debug

2 Likes

Oh I haven’t seen the Mathias’ reply yes it’s accurate thank you