En fait, je n'ai pas fait exactement le même script et n'utilise pas les mêmes ressources, j'ai juste du mal à adapter le code à ce que je veux vraiment. Mon menu de commandes est un menu distinct. Je n'ai pas de menu de carte ou de menu de quête. J'ai un menu d'inventaire qui va selon le tuto sur les inventaires pour Solarus 1.6, mais c'est tout.
local commands_highest_visible = 0
local commands_visible_y = 0
[...]
-- Create the commands names.
local command_names = {"action", "attack", "item_1", "item_2", "pause", "left", "right", "up", "down", }
local function set_cursor_position(position)
if position ~= cursor_position then
local width, height = sol.video.get_quest_size()
cursor_position = position
-- Make sure the selected command is visible.
while position <= commands_highest_visible do
commands_highest_visible = commands_highest_visible - 1
commands_visible_y = commands_visible_y - 16
end
while position > commands_highest_visible + 5 do
commands_highest_visible = commands_highest_visible +1
commands_visible_y = commands_visible_y + 16
end
cursor_sprite.x = width/2 - 75
cursor_sprite.y = height/2 - 20 + 16 *(position - commands_highest_visible)
end
end
[...]
function commands_menu:on_command_pressed(command)
if command_customizing ~= nil then
error("commands_menu:on_command_pressed() should not called in this state")
end
local handled = false
if not handled then
if command == "right" then
sol.audio.play_sound("message_end")
sol.menu.stop(commands_menu)
game:set_suspended(false)
handled = true
--elseif command == "left" then
-- sol.audio.play_sound("message_end")
-- sol.menu.stop(commands_menu)
-- game:set_suspended(false)
-- handled = true
elseif command == "up" then
sol.audio.play_sound("cursor")
set_cursor_position((cursor_position) % 9 -1)
handled = true
elseif command == "down" then
sol.audio.play_sound("cursor")
set_cursor_position(cursor_position % 9 +1)
handled = true
elseif command == "action" then
waiting_for_command = true
local command_to_customize = command_names[cursor_position]
game:capture_command_binding(command_to_customize, function()
waiting_for_command = false
sol.audio.play_sound("danger")
load_command_texts()
end)
end
handled = true
end
return handled
end