Author Topic: Children of Solarus Dialog Script, How Does it Work?  (Read 284 times)

gmanplays@gmail.com

  • Newbie
  • *
  • Posts: 22
    • View Profile
Children of Solarus Dialog Script, How Does it Work?
« on: March 15, 2019, 09:58:33 pm »
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.

Max

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Re: Children of Solarus Dialog Script, How Does it Work?
« Reply #1 on: March 17, 2019, 03:00:14 pm »
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?

gmanplays@gmail.com

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Children of Solarus Dialog Script, How Does it Work?
« Reply #2 on: March 18, 2019, 10:27:59 pm »
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.
« Last Edit: March 18, 2019, 10:34:38 pm by gmanplays@gmail.com »

llamazing

  • Full Member
  • ***
  • Posts: 186
    • View Profile
Re: Children of Solarus Dialog Script, How Does it Work?
« Reply #3 on: March 19, 2019, 12:49:04 am »
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.

gmanplays@gmail.com

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Children of Solarus Dialog Script, How Does it Work?
« Reply #4 on: April 01, 2019, 06:22:23 am »
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.

Code: [Select]
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

YoshiMario2000

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: Children of Solarus Dialog Script, How Does it Work?
« Reply #5 on: April 01, 2019, 06:56:45 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?

gmanplays@gmail.com

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Children of Solarus Dialog Script, How Does it Work?
« Reply #6 on: April 02, 2019, 09:38:42 am »
There we go, now I got it forreal this time. Thanks everyone very much for their time.