1
Development / Re: Text box appearing when getting an item
« on: September 14, 2019, 12:13:09 am »
ok got it working by putting game:start_dialog("_treasure.sword.1") in function item:on_variant_changed(variant)
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
sol.language.get_dialog()
in the solarus documentation pdf and I think that might be what I'm missing but cant get it to work either. Is there a certain function in my sword.lua that it should be used in or something like that maybe?
local item = ...
local game = item:get_game()
function item:on_created()
item:set_savegame_variable("possession_sword")
end
function item:on_variant_changed(variant)
game:set_ability("sword", variant)
end
-- Main Lua script of the quest.
require("scripts/features")
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()
sol.language.set_language("en")
sol.main.load_settings()
math.randomseed(os.time())
-- Show the initial menus.
if #initial_menus_config == 0 then
return
end
for _, menu_script in ipairs(initial_menus_config) do
initial_menus[#initial_menus + 1] = require(menu_script)
end
local on_top = false -- To keep the debug menu on top.
sol.menu.start(sol.main, initial_menus[1], on_top)
for i, menu in ipairs(initial_menus) do
function menu:on_finished()
if sol.main.game ~= nil then
-- A game is already running (probably quick start with a debug key).
return
end
local next_menu = initial_menus[i + 1]
if next_menu ~= nil then
sol.menu.start(sol.main, next_menu)
end
end
end
end
-- Event called when the program stops.
function sol.main:on_finished()
sol.main.save_settings()
end
-- 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.
sol.video.set_fullscreen(not sol.video.is_fullscreen())
handled = true
elseif key == "f4" and modifiers.alt then
-- Alt + F4: stop the program.
sol.main.exit()
handled = true
elseif key == "escape" and sol.main.game == nil then
-- Escape in title screens: stop the program.
sol.main.exit()
handled = true
end
return handled
end
-- Starts a game.
function sol.main:start_savegame(game)
-- Skip initial menus if any.
for _, menu in ipairs(initial_menus) do
sol.menu.stop(menu)
end
sol.main.game = game
game:start()
end