Solarus > Development

Text box appearing when getting an item

(1/5) > >>

Im probably missing something really simple but I'm following the tutorials and I'm trying to get dialog's to work right now when getting an item when opening a chest for example. In the tutorial it says to add sol.language.set_language("en") to main.lua but that didn't help at all and when I looked at a sample quest it didn't have that line of code in it either but still had text pop up when opening a chest and getting a sword. I also know I have the text setup in dialogs.dat the exact same as in the tutorial. Has something changed since the tutorial and I need to do something different to get dialog's working?

do you get an error when you open the chest?

what does your main.lua look like? paste it after clicking the hashtag icon "insert code" button. (12th button 2nd row)

in the quest editor when you click on languages there will be an "en"...right click that and "open dialogs" to get to the dialog editor and if you havent got a dialog for that item..the rest are under _treasure.sword.1, _treasure.shield.1, ect...

Thanks for the reply! No I dont get any errors and my dialog editor has dialog for my items under _treasure.sword.1, _treasure.shield.1 etc...

Here is the main.lua code:

--- Code: ----- Main Lua script of the quest.

local initial_menus_config = require("scripts/menus/initial_menus_config")
local initial_menus = {}

-- This function is called when Solarus starts.
function sol.main:on_started()



  -- Show the initial menus.
  if #initial_menus_config == 0 then

  for _, menu_script in ipairs(initial_menus_config) do
    initial_menus[#initial_menus + 1] = require(menu_script)

  local on_top = false  -- To keep the debug menu on top., initial_menus[1], on_top)
  for i, menu in ipairs(initial_menus) do
    function menu:on_finished()
      if ~= nil then
        -- A game is already running (probably quick start with a debug key).
      local next_menu = initial_menus[i + 1]
      if next_menu ~= nil then, next_menu)


-- Event called when the program stops.
function sol.main:on_finished()


-- Event called when the player pressed a keyboard key.
function sol.main:on_key_pressed(key, modifiers)

  local handled = false
  if key == "f11" or
    (key == "return" and (modifiers.alt or modifiers.control)) then
    -- F11 or Ctrl + return or Alt + Return: switch fullscreen.
    handled = true
  elseif key == "f4" and modifiers.alt then
    -- Alt + F4: stop the program.
    handled = true
  elseif key == "escape" and == nil then
    -- Escape in title screens: stop the program.
    handled = true

  return handled

-- Starts a game.
function sol.main:start_savegame(game)

  -- Skip initial menus if any.
  for _, menu in ipairs(initial_menus) do
  end = game

--- End code ---

Also as a side note I do get the save and quit text so it shouldn't be because I don't have a language set

Thanks again for the suggestions and help

Hmm, it's probably just a small mistake, but it's hard to say where if you aren't getting error messages.

If you set the item as a pickable, instead of in a chest, do you still not get the dialogue? If there's no dialogue for an item you pick up as a pickable, there will just be a 1-2 second pause where the hero is holding the item and nothing is happening. If that pause is happening, it's definitely the item not finding the dialog. Does the item's script have item:set_brandish()? The item might be not displaying the dialog because of some code in the item.

When its set as a pickupable I still dont get the text but it plays the animation. I think your right about the item just not having the script that calls for the text because I dont see any code for it in the items script. This is the script for the sword:

--- Code: ---local item = ...
local game = item:get_game()

function item:on_created()

function item:on_variant_changed(variant)
  game:set_ability("sword", variant)
--- End code ---

Thanks again for the help!


[0] Message Index

[#] Next page

Go to full version