Author Topic: New "debug_dialogs" script  (Read 231 times)

Diarandor

  • Hero Member
  • *****
  • Posts: 935
  • Cats are cool! (ΦωΦ)
    • View Profile
New "debug_dialogs" script
« on: March 08, 2018, 01:45:16 am »
I made a useful script to debug dialogs in our projects: debug_dialogs.lua
https://github.com/solarus-games/children-of-solarus/blob/master/data/scripts/debug_dialogs.lua
I tested it and it works perfect with dialogs without extra info/variables.
I haven't tested it with dialogs that need extra info/variables, so there may be issues in those cases, and I don't know how we could avoid those errors, although I think that does not matter so much.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Max

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Re: New "debug_dialogs" script
« Reply #1 on: March 21, 2018, 05:46:42 pm »
So, what exactly does this do? I looked it over, and I thiiink it will just one-by-one basically do game:start_dialog() for every dialog in your game so you can check them? That's cool. How would you go about calling this, just have an NPC that you delete later whose script requires this debug script and calls game_meta:start_dialogs_debug()?

Diarandor

  • Hero Member
  • *****
  • Posts: 935
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: New "debug_dialogs" script
« Reply #2 on: March 22, 2018, 12:04:33 am »
So, what exactly does this do? I looked it over, and I thiiink it will just one-by-one basically do game:start_dialog() for every dialog in your game so you can check them? That's cool. How would you go about calling this, just have an NPC that you delete later whose script requires this debug script and calls game_meta:start_dialogs_debug()?

Yes, but you can also start only a few dialogs if you add the optional parameters to the property list:
Code: Lua
  1. --[[ Get dialog ids list, ordered alphabetically. Default variables:
  2. language (string, optional): if nil, the default language is used.
  3. prefix (string, optional): prefix required for dialog ids.
  4. start_dialog (string, optional): start from this one; by default: first dialog.
  5. end_dialog (string, optional): ends in this one; by default: last dialog.
  6. --]]
  7. function game_meta:start_dialogs_debug(dialog_properties)

For instance, use
Code: Lua
  1. game:start_dialogs_debug({prefix = "blablabla"})
to start only the dialogs with the prefix "blablabla", or
Code: Lua
  1. game:start_dialogs_debug({start_dialog = "c", end_dialog = "f"})
to start only the dialogs whose ids are between "c" and "f" with the order for strings (which in Lua is the order of the dictionary).

-You can call those codes from the console or from Lua code (map scripts, etc). Yes, using an NPC is a way to use the code.
-Note that some errors may appear for dialogs that require input variables, since the script cannot guess when they are needed, their types, or how many of them appear.
« Last Edit: March 22, 2018, 01:15:32 am by Diarandor »
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”