Children of Solarus Dialog Script, How Does it Work?

Started by gmanplays@gmail.com, March 15, 2019, 09:58:33 PM

Previous topic - Next topic
Hey again,

I've been playing around with the dialog scripts from Children of Solarus, in particular debug_dialog, dialog_box, and language_manager (I think that's right..?). However, upon inspection I can't figure out how to index the dialog ids I need to in order to start the loop, which I think is the function that'll let me rattle off multiple dialog boxes without generating the "dialog already active" exception. Maybe I've skimmed over some comment that gives instructions on that matter, but upon close inspection I don't think I have. I've also referenced back to the original tutorials, but those didn't help because all of the dialog boxes shown there are separated by input, whereas I just need to show two consecutive dialog boxes. Here's a link to each of those scripts, I was hoping I could reference the experience of someone who's already figured it out though.

dialog_box.lua: https://github.com/solarus-games/children-of-solarus/blob/dev/data/scripts/menus/dialog_box.lua
debug_dialog.lua: https://github.com/solarus-games/children-of-solarus/blob/dev/data/scripts/debug_dialogs.lua
language_manager.lua: https://github.com/solarus-games/children-of-solarus/blob/dev/data/scripts/language_manager.lua

Hope I don't waste anybody's time. Thanks much for reading.

You're not wasting anybody's time : )

So you just want to show two consecutive dialogs? Why not just show the second one in the first one's callback?

March 18, 2019, 10:27:59 PM #2 Last Edit: March 18, 2019, 10:34:38 PM by gmanplays@gmail.com
Wait, you can do that? I totally didn't think of that. I should probably start being more creative with the API reference info, huh? Anyways, thank you much.

--EDIT: It appears that when I put the second start_dialog command in the callback, it just skips the first dialog. Odd.

If all you want to do is show two dialogs back-to-back then all you have to do is use the "next" property of the dialog entry. For example:
Code (lua) Select

dialog{
  id = "first_dialog",
  next = "second_dialog",
  text = [[
show this dialog first.
]]}

dialog{
  id = "second_dialog",
  text = [[
Then show this dialog.
]]}


Then all you have to do is start the first dialog and the second one automatically gets shown after. Note that there is also a "next2" property for when the player selects from between 2 choices, where next2 is the dialog to display next when the second choice is selected.

So I've tried whatcha suggested, but it seems like a whole new error arose even still, and I think it's because I'm putting what you suggested in the wrong place. I was also unclear whether or not the text property was supposed to draw the dialog on the screen or print that text in the console. What am I missing here? Where can I find the info you used to get this straight? Here's the script, do you see anything wrong with it? Oh, and just for context, it's generating an exception that says it's trying to index a global variable called "dialog" that's nil.

local map = ...
local game = map:get_game()

-- Event called at initialization time, as soon as this map is loaded.
function map:on_started()
  map.small_keys_savegame_variable = "Underwell"
  require("scripts/language_manager")
  require("debug_dialog.lua")
  require("scripts/menus/dialog_box")
  require("scripts/menus/alttp_dialog_box")
end

function sensor:on_activated()
  game:set_ability("sword", 1)
  hero:start_victory(hero:freeze())
  hero:set_direction(3)
  sol.audio.play_sound("treasure")
  sol.timer.start(1000,function()
    sol.audio.play_music("sanctuary", true)
    dialog{
      id = "sword.first",
      next = "sword.second",
      text = [[
      show this dialog first.
      ]]}
    dialog{
      id = "sword.second",
      text = [[
      Then show this dialog.
      ]]}
    sol.audio.stop_music()
    sol.audio.play_music("light_world_dungeon", true)
    hero:unfreeze()
  end)
end

Quote from: llamazing on March 19, 2019, 12:49:04 AM
Code (lua) Select

dialog{
  id = "first_dialog",
  next = "second_dialog",
  text = [[
show this dialog first.
]]}

dialog{
  id = "second_dialog",
  text = [[
Then show this dialog.
]]}

This code is relevant to the the language.dat file, not your code. In code call the dialog as you normally would, I.E.
Code (lua) Select
game:start_dialog("sword.first")
Now you have two options from here for calling another dialog. You can either use the callback or, the much cleaner way, use the "next" property key.

I'm just using an image extracted from my own personal project (see attachment 1), so certain properties here are irrelevant (and don't work as the dialog script your using doesn't use these properties).
The value that the property key "next" should be the next dialog that you wish to call.
This signature was way too long before, but now it's short!
Also, I am Still Alive!
On ad Off I go!

Do you ever get the feeling that the fandom of a product(s) ruin the potential that you could have had to enjoy the product?

There we go, now I got it forreal this time. Thanks everyone very much for their time.