This is a very important new feature of Solarus 1.1. The dialog box system is now fully scriptable using the Lua API!
The syntax of the dialog files
If you don't make a scripted dialog box in Lua, the engine shows a minimal dialog box without decoration. But it is recommended to make your own one!
Here is an example of a small map script with a non-playing character that shows a simple dialog when the hero talks to him:
local map = ... function some_npc:on_interaction() -- Remember that you specify a dialog id, not directly the text to show. -- The text is defined in the dialogs.dat file of the current language. map:get_game():start_dialog("welcome_to_my_house") end
function some_npc:on_interaction() -- Remember that you specify a dialog id, not directly the text to show. -- The text is defined in the dialogs.dat file of the current language. map:get_game():start_dialog("welcome_to_my_house") end
local map = ... local game = map:get_game() function another_npc:on_interaction() game:start_dialog("give_me_100_rupees_please", function(answer) if answer then if game:get_money() >= 100 then game:remove_money(100) game:start_dialog("thanks") else sol.audio.play_sound("wrong") game:start_dialog("not_enough_money") end else game:start_dialog("not_happy") end end) end
function another_npc:on_interaction() game:start_dialog("give_me_100_rupees_please", function(answer) if answer then if game:get_money() >= 100 then game:remove_money(100) game:start_dialog("thanks") else sol.audio.play_sound("wrong") game:start_dialog("not_enough_money") end else game:start_dialog("not_happy") end end) end
Fore more details, see the documentation of game:start_dialog() in the Solarus Lua API.