Author Topic: Alttp Dialog box + sample quest bug  (Read 461 times)

Zefk

  • Sr. Member
  • ****
  • Posts: 482
  • Just helping Solarus
    • View Profile
    • Zelzec Business
Alttp Dialog box + sample quest bug
« on: December 14, 2016, 05:47:08 pm »
The mouse contol function seems to make the alttp dialog box script not work.

This function is the issue. The alttp dialog box works without it.
Code: Lua
  1.   function game:on_started()
  2.     -- HUD menu.
  3.     local hud = require("scripts/menus/hud")
  4.     sol.menu.start(game, hud)
  5.     hud:create(game)
  6.  
  7.     -- Mouse control.
  8.     local mouse_control = require("scripts/menus/mouse_control")
  9.     sol.menu.start(game, mouse_control)
  10.     mouse_control:create(game, hud)
  11.  
  12.     local hero = game:get_hero()
  13.     hero:set_tunic_sprite_id("main_heroes/eldran")
  14.   end

Full code:
Code: Lua
  1. require("scripts/menus/alttp_dialog_box")
  2. local game_manager = {}
  3.  
  4. -- Starts the game from the given savegame file,
  5. -- initializing it if necessary.
  6. function game_manager:start_game()
  7.  
  8.   local exists = sol.game.exists("save1.dat")
  9.   local game = sol.game.load("save1.dat")
  10.   if not exists then
  11.     -- Initialize a new savegame.
  12.     game:set_max_life(12)
  13.     game:set_life(game:get_max_life())
  14.     game:set_ability("lift", 2)
  15.     game:set_ability("sword", 1)
  16.     game:set_starting_location("first_map") -- Starting location.
  17.   end
  18.  
  19.   function game:on_started()
  20.     -- HUD menu.
  21.     local hud = require("scripts/menus/hud")
  22.     sol.menu.start(game, hud)
  23.     hud:create(game)
  24.  
  25.     -- Mouse control.
  26.     local mouse_control = require("scripts/menus/mouse_control")
  27.     sol.menu.start(game, mouse_control)
  28.     mouse_control:create(game, hud)
  29.  
  30.     local hero = game:get_hero()
  31.     hero:set_tunic_sprite_id("main_heroes/eldran")
  32.   end
  33.   game:start()
  34.  
  35.   local hero = game:get_hero()
  36.   hero:set_tunic_sprite_id("main_heroes/eldran")
  37. end
  38.  
  39. return game_manager

MetalZelda

  • Sr. Member
  • ****
  • Posts: 479
    • View Profile
Re: Alttp Dialog box + sample quest bug
« Reply #1 on: December 14, 2016, 09:26:20 pm »
Can we have a look on the ALTTP dialog box script ?

This might be because the script need to be initialized.
Any errors ?

Zefk

  • Sr. Member
  • ****
  • Posts: 482
  • Just helping Solarus
    • View Profile
    • Zelzec Business
Re: Alttp Dialog box + sample quest bug
« Reply #2 on: December 15, 2016, 12:55:19 am »
Alttp dialog script:

No errors....

Code: Lua
  1. -- Script that creates an ALTTP-looking dialog box for games.
  2. --
  3. -- Usage:
  4. -- require("scripts/menus/alttp_dialog_box")
  5. --
  6. -- You really have nothing more to do:
  7. -- the dialog box will automatically be used in games.
  8. --
  9. -- To customize the dialog box, call
  10. -- local dialog_box = game:get_dialog_box()
  11. -- to get it and then it provides the following functions:
  12. --
  13. -- - dialog_box:set_style(style):
  14. --   Sets the style of the dialog box for subsequent dialogs.
  15. --   style must be one of:
  16. --   - "box" (default): Usual dialog box.
  17. --   - "empty": No decoration.
  18. --
  19. -- - dialog_box:set_position(position):
  20. --   Sets the vertical position of the dialog box for subsequent dialogs.
  21. --   position must be one of:
  22. --   - "auto": Choose automatically so that the hero is not hidden.
  23. --   - "top": Top of the screen.
  24. --   - "bottom" (default): Bottom of the screen.
  25. --   - a table with x and y integer fields.
  26. --
  27. -- - dialog_box:get_bounding_box():
  28. --   Returns the coordinates on screen and the size of the dialog box.
  29. --   This also works when the dialog box is inactive: in this case it
  30. --   returns the bounding box it would have if it was activated now.
  31.  
  32. local dialog_box_manager = {}
  33.  
  34. require("scripts/multi_events")
  35.  
  36. -- Creates and sets up a dialog box for the specified game.
  37. local function create_dialog_box(game)
  38.  
  39.   local dialog_box = {
  40.  
  41.     -- Dialog box properties.
  42.     dialog = nil,                -- Dialog being displayed or nil.
  43.     first = true,                -- Whether this is the first dialog of a sequence.
  44.     style = nil,                 -- "box" or "empty".
  45.     position = "bottom",         -- "auto", "top", "bottom" or an x,y table.
  46.     skip_mode = nil,             -- "none", "current", "all" or "unchanged".
  47.     info = nil,                  -- Parameter passed to start_dialog().
  48.     skipped = false,             -- Whether the player skipped the dialog.
  49.     choices = {},                -- Whether there is a choice on each line. If yes,
  50.                                  -- the value is the char index of the cursor.
  51.     selected_choice = nil,       -- Selected line (1 is the first one) or nil if there is no question.
  52.  
  53.     -- Displaying text gradually.
  54.     next_line = nil,             -- Next line to display or nil.
  55.     line_it = nil,               -- Iterator over of all lines of the dialog.
  56.     lines = {},                  -- Array of the text of the visible lines.
  57.     line_surfaces = {},          -- Array of the nb_visible_lines text surfaces.
  58.     line_index = nil,            -- Line currently being shown.
  59.     char_index = nil,            -- Next character to show in the current line.
  60.     char_delay = nil,            -- Delay between two characters in milliseconds.
  61.     full = false,                -- Whether the visible lines have shown all their content.
  62.     need_letter_sound = false,   -- Whether a sound should be played with the next character.
  63.     gradual = true,              -- Whether text is displayed gradually.
  64.  
  65.     -- Graphics.
  66.     dialog_surface = nil,        -- Intermediate surface where we draw the dialog.
  67.     box_img = nil,               -- Image of the dialog box frame.
  68.     box_dst_position = nil,      -- Destination coordinates of the dialog box.
  69.     choice_cursor_img = nil,     -- Icon representing the selected choice in a question.
  70.     choice_cursor_dst_position = -- Destination coordinates of the cursor icon.
  71.         nil,
  72.   }
  73.  
  74.   -- Constants.
  75.   local nb_visible_lines = 4     -- Maximum number of lines in the dialog box.
  76.   local char_delays = {
  77.     slow = 60,
  78.     medium = 40,
  79.     fast = 20  -- Default.
  80.   }
  81.   local letter_sound_delay = 100
  82.   local box_width = 220
  83.   local box_height = 60
  84.  
  85.   -- Initialize dialog box data.
  86.   local dialog_font, dialog_font_size = "alttp", nil
  87.   for i = 1, nb_visible_lines do
  88.     dialog_box.lines[i] = ""
  89.     dialog_box.line_surfaces[i] = sol.text_surface.create{
  90.       horizontal_alignment = "left",
  91.       vertical_alignment = "top",
  92.       font = dialog_font,
  93.       font_size = dialog_font_size,
  94.     }
  95.   end
  96.   dialog_box.dialog_surface = sol.surface.create(sol.video.get_quest_size())
  97.   dialog_box.box_img = sol.surface.create("hud/dialog_box.png")
  98.   dialog_box.choice_cursor_img = sol.text_surface.create{
  99.     horizontal_alignment = "left",
  100.     vertical_alignment = "top",
  101.     font = dialog_font,
  102.       font_size = dialog_font_size,
  103.     text = ">",
  104.   }
  105.  
  106.   -- Exits the dialog box system.
  107.   function dialog_box:quit()
  108.     if sol.menu.is_started(dialog_box) then
  109.       sol.menu.stop(dialog_box)
  110.     end
  111.   end
  112.  
  113.   -- Called by the engine when a dialog starts.
  114.   function game:on_dialog_started(dialog, info)
  115.  
  116.     dialog_box.dialog = dialog
  117.     dialog_box.info = info
  118.     sol.menu.start(game, dialog_box)
  119.   end
  120.  
  121.   -- Called by the engine when a dialog finishes.
  122.   function game:on_dialog_finished(dialog)
  123.  
  124.     if sol.menu.is_started(dialog_box) then
  125.       sol.menu.stop(dialog_box)
  126.     end
  127.     dialog_box.dialog = nil
  128.     dialog_box.info = nil
  129.   end
  130.  
  131.   -- Determines the position of the dialog box on the screen.
  132.   local function compute_position()
  133.  
  134.     local map = game:get_map()
  135.     local camera_x, camera_y, camera_width, camera_height = map:get_camera():get_bounding_box()
  136.     local top = false
  137.     if dialog_box.position == "top" then
  138.       top = true
  139.     elseif dialog_box.position == "auto" then
  140.       local hero_x, hero_y = map:get_entity("hero"):get_position()
  141.       if hero_y >= camera_y + (camera_height / 2 + 10) then
  142.         top = true
  143.       end
  144.     end
  145.  
  146.     -- Set the coordinates of graphic objects.
  147.     local box_width, box_height = dialog_box.box_img:get_size()
  148.     local x = camera_width / 2 - box_width / 2
  149.     local y = top and x or (camera_height - x - box_height)
  150.  
  151.     if type(dialog_box.position) == "table" then
  152.       -- Custom position.
  153.       dialog_box.box_dst_position = dialog_box.position
  154.     else
  155.       dialog_box.box_dst_position = { x = x, y = y }
  156.     end
  157.   end
  158.  
  159.   -- Returns the dialog box.
  160.   function game:get_dialog_box()
  161.     return dialog_box
  162.   end
  163.  
  164.   -- See the doc in the header comment.
  165.   function dialog_box:set_style(style)
  166.  
  167.     dialog_box.style = style
  168.   end
  169.  
  170.   -- See the doc in the header comment.
  171.   function dialog_box:set_position(position)
  172.     dialog_box.position = position
  173.   end
  174.  
  175.   -- See the doc in the header comment.
  176.   function dialog_box:get_bounding_box()
  177.     compute_position()
  178.     local width, height = self.box_img:get_size()
  179.     return self.box_dst_position.x, self.box_dst_position.y, width, height
  180.   end
  181.  
  182.   local function repeat_show_character()
  183.  
  184.     dialog_box:check_full()
  185.     while not dialog_box:is_full()
  186.         and dialog_box.char_index > #dialog_box.lines[dialog_box.line_index] do
  187.       -- The current line is finished.
  188.       dialog_box.char_index = 1
  189.       dialog_box.line_index = dialog_box.line_index + 1
  190.       dialog_box:check_full()
  191.     end
  192.  
  193.     if not dialog_box:is_full() then
  194.       dialog_box:add_character()
  195.     else
  196.       sol.audio.play_sound("message_end")
  197.       if game.set_custom_command_effect ~= nil then
  198.         if dialog_box:has_more_lines()
  199.             or dialog_box.dialog.next ~= nil
  200.             or dialog_box.selected_choice ~= nil then
  201.           game:set_custom_command_effect("action", "next")
  202.         else
  203.           game:set_custom_command_effect("action", "return")
  204.         end
  205.         game:set_custom_command_effect("attack", nil)
  206.       end
  207.     end
  208.   end
  209.  
  210.   -- The first dialog of a sequence starts.
  211.   function dialog_box:on_started()
  212.  
  213.     -- Set the initial properties.
  214.     -- Subsequent dialogs in the same sequence do not reset them.
  215.     self.skip_mode = "current"
  216.     self.char_delay = char_delays["fast"]
  217.     self.selected_choice = nil
  218.  
  219.     compute_position()
  220.     self.choice_cursor_dst_position = { x = 0, y = 0 }
  221.  
  222.     self:show_dialog()
  223.   end
  224.  
  225.   -- The dialog box is being closed.
  226.   function dialog_box:on_finished()
  227.  
  228.     -- Remove overriden command effects.
  229.     if game.set_custom_command_effect ~= nil then
  230.       game:set_custom_command_effect("action", nil)
  231.       game:set_custom_command_effect("attack", nil)
  232.     end
  233.   end
  234.  
  235.   -- A dialog starts (not necessarily the first one of its sequence).
  236.   function dialog_box:show_dialog()
  237.  
  238.     -- Initialize this dialog.
  239.     local dialog = self.dialog
  240.  
  241.     local text = dialog.text
  242.     if dialog_box.info ~= nil then
  243.       -- There is a "$v" sequence to substitute.
  244.       text = text:gsub("%$v", dialog_box.info)
  245.     end
  246.     -- Split the text in lines.
  247.     text = text:gsub("\r\n", "\n"):gsub("\r", "\n")
  248.     self.line_it = text:gmatch("([^\n]*)\n")  -- Each line including empty ones.
  249.  
  250.     self.next_line = self.line_it()
  251.     self.line_index = 1
  252.     self.char_index = 1
  253.     self.skipped = false
  254.     self.full = false
  255.     self.need_letter_sound = true
  256.     self.selected_choice = nil
  257.  
  258.     if dialog.skip ~= nil then
  259.       -- The skip mode changes for this dialog.
  260.       self.skip_mode = dialog.skip
  261.     end
  262.  
  263.     -- Start displaying text.
  264.     self:show_more_lines()
  265.   end
  266.  
  267.   -- Returns whether there are more lines remaining to display after the current
  268.   -- group of nb_visible_lines lines.
  269.   function dialog_box:has_more_lines()
  270.     return self.next_line ~= nil
  271.   end
  272.  
  273.   -- Updates the result of is_full().
  274.   function dialog_box:check_full()
  275.     if self.line_index >= nb_visible_lines
  276.         and self.char_index > #self.lines[nb_visible_lines] then
  277.       self.full = true
  278.     else
  279.       self.full = false
  280.     end
  281.   end
  282.  
  283.   -- Returns whether all current lines of the dialog box are entirely
  284.   -- displayed.
  285.   function dialog_box:is_full()
  286.     return self.full
  287.   end
  288.  
  289.   -- Shows the next dialog of the sequence.
  290.   -- Closes the dialog box if there is no next dialog.
  291.   function dialog_box:show_next_dialog()
  292.  
  293.     local next_dialog_id = self.dialog.next
  294.  
  295.     if next_dialog_id ~= nil then
  296.       -- Show the next dialog.
  297.       self.first = false
  298.       self.selected_choice = nil
  299.       self.dialog = sol.language.get_dialog(next_dialog_id)
  300.       self:show_dialog()
  301.     else
  302.       -- Finish the dialog, returning the choice or nil if there was no question.
  303.       local status = self.selected_choice
  304.  
  305.       -- Conform to the built-in handling of shop treasures.
  306.       if self.dialog.id == "_shop.question" then
  307.         -- The engine expects a boolean answer after the "do you want to buy"
  308.         -- shop treasure dialog.
  309.         status = self.selected_choice == 2  -- "Yes" is on the second line.
  310.       end
  311.  
  312.       game:stop_dialog(status)
  313.     end
  314.   end
  315.  
  316.   -- Starts showing a new group of nb_visible_lines lines in the dialog.
  317.   -- Shows the next dialog (if any) if there are no remaining lines.
  318.   function dialog_box:show_more_lines()
  319.  
  320.     self.gradual = true
  321.  
  322.     if not self:has_more_lines() then
  323.       self:show_next_dialog()
  324.       return
  325.     end
  326.  
  327.     -- Hide the action icon and change the sword icon.
  328.     if game.set_custom_command_effect ~= nil then
  329.       game:set_custom_command_effect("action", nil)
  330.       if self.skip_mode ~= "none" then
  331.         game:set_custom_command_effect("attack", "skip")
  332.         game:set_custom_command_effect("action", "next")
  333.       else
  334.         game:set_custom_command_effect("attack", nil)
  335.       end
  336.     end
  337.  
  338.     -- Prepare the lines.
  339.     for i = 1, nb_visible_lines do
  340.       self.line_surfaces[i]:set_text("")
  341.       if self:has_more_lines() then
  342.         self.lines[i] = self.next_line
  343.         self.next_line = self.line_it()
  344.       else
  345.         self.lines[i] = ""
  346.       end
  347.     end
  348.     self.line_index = 1
  349.     self.char_index = 1
  350.  
  351.     if self.gradual then
  352.       sol.timer.start(self, self.char_delay, repeat_show_character)
  353.     end
  354.   end
  355.  
  356.   -- Adds the next character to the dialog box.
  357.   -- If this is a special character (like $0, $v, etc.),
  358.   -- the corresponding action is performed.
  359.   function dialog_box:add_character()
  360.  
  361.     local line = self.lines[self.line_index]
  362.     local current_char = line:sub(self.char_index, self.char_index)
  363.     if current_char == "" then
  364.       error("No remaining character to add on this line")
  365.     end
  366.     self.char_index = self.char_index + 1
  367.     local additional_delay = 0
  368.     local text_surface = self.line_surfaces[self.line_index]
  369.  
  370.     -- Special characters:
  371.     -- - $1, $2 and $3: slow, medium and fast
  372.     -- - $0: pause
  373.     -- - $v: variable
  374.     -- - $?: cursor for a choice
  375.     -- - space: don't add the delay
  376.     -- - 110xxxx: multibyte character
  377.  
  378.     local special = false
  379.     if current_char == "$" then
  380.       -- Special character.
  381.  
  382.       special = true
  383.       current_char = line:sub(self.char_index, self.char_index)
  384.       self.char_index = self.char_index + 1
  385.  
  386.       if current_char == "0" then
  387.         -- Pause.
  388.         additional_delay = 1000
  389.  
  390.       elseif current_char == "1" then
  391.         -- Slow.
  392.         self.char_delay = char_delays["slow"]
  393.  
  394.       elseif current_char == "2" then
  395.         -- Medium.
  396.         self.char_delay = char_delays["medium"]
  397.  
  398.       elseif current_char == "3" then
  399.         -- Fast.
  400.         self.char_delay = char_delays["fast"]
  401.  
  402.       elseif current_char == "?" then
  403.         -- Cursor for a choice.
  404.         self:add_choice(self.line_index, self.char_index - 2)
  405.         current_char = " "
  406.         special = false
  407.       else
  408.         -- Not a special char, actually.
  409.         text_surface:set_text(text_surface:get_text() .. "$")
  410.         special = false
  411.       end
  412.     end
  413.  
  414.     if not special then
  415.       -- Normal character to be displayed.
  416.       text_surface:set_text(text_surface:get_text() .. current_char)
  417.  
  418.       -- If this is a multibyte character, also add the next byte.
  419.       local byte = current_char:byte()
  420.       if byte >= 192 and byte < 224 then
  421.         -- The first byte is 110xxxxx: the character is stored with
  422.         -- two bytes (utf-8).
  423.         current_char = line:sub(self.char_index, self.char_index)
  424.         self.char_index = self.char_index + 1
  425.         text_surface:set_text(text_surface:get_text() .. current_char)
  426.       end
  427.  
  428.       if current_char == " " then
  429.         -- Remove the delay for whitespace characters.
  430.         additional_delay = -self.char_delay
  431.       end
  432.     end
  433.  
  434.     if not special and current_char ~= nil and self.need_letter_sound then
  435.       -- Play a letter sound sometimes.
  436.       sol.audio.play_sound("message_letter")
  437.       self.need_letter_sound = false
  438.       sol.timer.start(self, letter_sound_delay, function()
  439.         self.need_letter_sound = true
  440.       end)
  441.     end
  442.  
  443.     if self.gradual then
  444.       sol.timer.start(self, self.char_delay + additional_delay, repeat_show_character)
  445.     end
  446.   end
  447.  
  448.   -- Stops displaying gradually the current lines,
  449.   -- shows them immediately.
  450.   -- If the lines were already finished, the next group of lines starts
  451.   -- (if any).
  452.   function dialog_box:show_all_now()
  453.  
  454.     if self:is_full() then
  455.       self:show_more_lines()
  456.     else
  457.       self.gradual = false
  458.       -- Check the end of the current line.
  459.       self:check_full()
  460.       while not self:is_full() do
  461.  
  462.         while not self:is_full()
  463.             and self.char_index > #self.lines[self.line_index] do
  464.           self.char_index = 1
  465.           self.line_index = self.line_index + 1
  466.           self:check_full()
  467.         end
  468.  
  469.         if not self:is_full() then
  470.           self:add_character()
  471.         end
  472.         self:check_full()
  473.       end
  474.     end
  475.   end
  476.  
  477.   -- Marks that a line contains a selectable choice.
  478.   -- A cursor will be displayed at the specified index when this
  479.   -- line is selected.
  480.   function dialog_box:add_choice(line_index, char_index)
  481.  
  482.     self.choices[line_index] = char_index
  483.     if self.selected_choice == nil then
  484.       self:set_selected_choice(line_index)
  485.     end
  486.   end
  487.  
  488.   function dialog_box:set_selected_choice(line_index)
  489.  
  490.     self.selected_choice = line_index
  491.  
  492.     if line_index ~= nil then
  493.       self.choice_cursor_dst_position.x = self.box_dst_position.x + self.choices[line_index] * 6
  494.       self.choice_cursor_dst_position.y = self.box_dst_position.y - 8 + line_index * 16
  495.     end
  496.   end
  497.  
  498.   function dialog_box:on_command_pressed(command)
  499.  
  500.     if command == "action" then
  501.  
  502.       -- Display more lines.
  503.       if self:is_full() then
  504.         self:show_more_lines()
  505.       elseif self.skip_mode ~= "none" then
  506.         self:show_all_now()
  507.       end
  508.  
  509.     elseif command == "attack" then
  510.  
  511.       -- Attempt to skip the dialog.
  512.       if self.skip_mode == "all" then
  513.         self.skipped = true
  514.         game:stop_dialog("skipped")
  515.       elseif self:is_full() then
  516.         self:show_more_lines()
  517.       elseif self.skip_mode == "current" then
  518.         self:show_all_now()
  519.       end
  520.  
  521.     elseif command == "up" or command == "down" then
  522.  
  523.       if self.selected_choice ~= nil
  524.           and not self:has_more_lines()
  525.           and self:is_full() then
  526.  
  527.         sol.audio.play_sound("cursor")
  528.         local line_index = self.selected_choice
  529.  
  530.         if command == "down" then
  531.           -- Move the cursor downwards.
  532.           repeat
  533.             line_index = line_index % nb_visible_lines + 1
  534.           until self.choices[line_index] ~= nil
  535.         else
  536.           -- Move the cursor upwards.
  537.           repeat
  538.             line_index = (line_index - 2) % nb_visible_lines + 1
  539.           until self.choices[line_index] ~= nil
  540.         end
  541.         self:set_selected_choice(line_index)
  542.       end
  543.     end
  544.  
  545.     -- Don't propagate the event to anything below the dialog box.
  546.     return true
  547.   end
  548.  
  549.   function dialog_box:on_draw(dst_surface)
  550.  
  551.     local x, y = self.box_dst_position.x, self.box_dst_position.y
  552.  
  553.     self.dialog_surface:clear()
  554.  
  555.     if self.style == "box" then
  556.       -- Draw the dialog box.
  557.       self.box_img:draw(self.dialog_surface, x, y)
  558.     end
  559.  
  560.     -- Draw the text.
  561.     local text_x = x + 8
  562.     local text_y = y + 8
  563.     for i = 1, nb_visible_lines do
  564.       self.line_surfaces[i]:draw(self.dialog_surface, text_x, text_y)
  565.       text_y = text_y + 16
  566.     end
  567.  
  568.     -- Draw the answer arrow.
  569.     if self.selected_choice ~= nil then
  570.       self.choice_cursor_img:draw(self.dialog_surface,
  571.           self.choice_cursor_dst_position.x, self.choice_cursor_dst_position.y)
  572.     end
  573.  
  574.     -- Final blit.
  575.     self.dialog_surface:draw(dst_surface)
  576.   end
  577.  
  578.   dialog_box:set_style("box")
  579. end
  580.  
  581. -- Set up the dialog box on any game that starts.
  582. local game_meta = sol.main.get_metatable("game")
  583. game_meta:register_event("on_started", create_dialog_box)
  584.  
  585. return dialog_box_manager
  586.  
« Last Edit: December 15, 2016, 04:33:14 am by Zefk »

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1008
    • View Profile
Re: Alttp Dialog box + sample quest bug
« Reply #3 on: December 15, 2016, 10:37:15 am »
The problem is that the scripts from the sample quest are not yet as modular as more recent scripts I made. There is an issue about that: https://github.com/solarus-games/solarus-sample-quest/issues/1

To be more specific, the sample quest scripts do not use the multi_events script (yet), so they don't mix well with scripts from the ALTTP pack like the ALTTP dialog box. I will improve that soon, but here is a solution in the meantime:

In your game_manager script, add require("scripts/multi_events") at the beginning, and then replace
Code: Lua
  1. function game:on_started()
  2.   ...
  3. end
  4.  
by
Code: Lua
  1. game:register_event("on_started", function()
  2.   ...
  3. end)
  4.  
Then the ALTTP dialog box should work well with the sample quest :)

Zefk

  • Sr. Member
  • ****
  • Posts: 482
  • Just helping Solarus
    • View Profile
    • Zelzec Business
Re: Alttp Dialog box + sample quest bug
« Reply #4 on: December 29, 2016, 07:38:17 am »
Thank you Christopho! It worked perfectly.

Here is the code for anyone that wants it.

Code: Lua
  1.  game:register_event("on_started", function()
  2.     -- HUD menu.
  3.     local hud = require("scripts/menus/hud")
  4.     sol.menu.start(game, hud)
  5.     hud:create(game)
  6.  
  7.     -- Mouse control.
  8.     local mouse_control = require("scripts/menus/mouse_control")
  9.     sol.menu.start(game, mouse_control)
  10.     mouse_control:create(game, hud)
  11.  
  12.     local hero = game:get_hero()
  13.     hero:set_tunic_sprite_id("main_heroes/eldran")
  14.  end)