Dialog boxes in 1.1

Started by Vulpo, October 16, 2013, 11:07:48 PM

Previous topic - Next topic
October 16, 2013, 11:07:48 PM Last Edit: October 16, 2013, 11:10:10 PM by Vulpo
Hi, I am following the tutorials, but the beginning of the 5th chapter let me quite confuse.

When I try to start a dialog with 'd', I only get a floating text with no frame, and I can not close the dialog, nor have a cursor to make a choice for "question=true" dialogs. And I will stay stuck on this window unless I rework on_dialog_finished(), sol.main:on_key_pressed(key) and create a new "key_pressed_on_dialog(key)" function.
My code without this rework is quite similar to the one in the tuto but adapted for version 1.1. Here is the chunk :

function game_manager.create(file)
--create the game (but not start it)
game = sol.game.load(file)

        --menu management
game.on_paused = function()
in_dialog = true
game:start_dialog("pause_menu", function(answer)
                                --it gets stucks even before getting there
if answer==1 then

I did not override on_dialog_started(), but neither did christopho in the tutos and yet he has decent dialog boxes. If this change is due to the migration 1.0 -> 1.1, then it seems to me like a quite hudge work to rebuild the yes/no question dialogs from scratch, and this is only the beginning.

Am I missing something ?

October 18, 2013, 07:38:22 AM #1 Last Edit: October 18, 2013, 08:04:07 AM by Renkineko
Have you read the whole migration guide ? The dialog box has been completely changed and you have to slightly modify some portions of code. You can watch the video (only in french but you can still look at what is done in the code and what are the actions) to have a better idea of what you have to do to make the dialog works in the 1.1 version.

The problem of the empty box has been encountered in the video, around here. If you look at your error.txt, does it say "attempt to call method 'set_custom_command_effect' (a nil value)" ? If yes, you have to search in the code of the dialog box for this function and comment it, or create on your game an empty function 'set_custom_command_effect'.

Never forget to read the error.txt or precise if it's empty, it's THE file for debug ;)

Christopho will correct me if I'm wrong :)

Welcome on the forum :)

The dialog box system has indeed completely changed between 1.0 and 1.1.

In Solarus 1.0, the dialog box is built-in in the engine. You call start_dialog() from Lua and that's it.

In Solarus 1.1, the dialog box *can* be scripted in Lua. There are two options:
- If you define game:on_dialog_started(), then your dialog box is in pure Lua. The engine does strictly nothing except suspending the game until you call game:stop_dialog().
- If you *don't* define game:on_dialog_started(), then there is a built-in, very minimal dialog box in the engine. Just text displayed immediately, without any frame, without a cursor for a question, etc. That's your case. But what you are saying is strange because you can normally close the dialog box by pressing the action key.

October 18, 2013, 02:58:13 PM #3 Last Edit: October 22, 2013, 12:48:33 AM by Vulpo
Many thanks both of you for your reply  :)

I watched video 1-5 but did not check video 21, since I did not know (but should have guessed) that it will cover the version changes. But nothing has been reported in my error.txt file, which usually works. Today I just had a lot of work to do for the week-end, but for sure I will try again Sunday !!

PS : Just in case it matters, I compilled solarus from source on Fedora 19 and am using Lua 5.1.4.

edit : I have so much work... I couldn't do it Sunday, I hope I'll have the time this week. When I try again, I'll let you know.