Solarus-Games English Forum

Community => Your scripts => Topic started by: Diarandor on March 08, 2018, 01:45:16 AM

Title: New "debug_dialogs" script
Post by: Diarandor 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.
Title: Re: New "debug_dialogs" script
Post by: Max 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()?
Title: Re: New "debug_dialogs" script
Post by: Diarandor on March 22, 2018, 12:04:33 AM
Quote from: Max 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()?

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


For instance, use
Code (Lua) Select
game:start_dialogs_debug({prefix = "blablabla"})
to start only the dialogs with the prefix "blablabla", or
Code (Lua) Select
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.