Author Topic: Résolu : Menu de game-over + inventaire en 1.6  (Read 565 times)

Lucifer

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Mon site
Résolu : Menu de game-over + inventaire en 1.6
« on: January 14, 2018, 07:04:56 pm »
Bonsoir à tous !
Alors, je crée un jeu avec Solarus, mais je voudrais coder un menu de game-over ainsi qu'un inventaire, car quand je l'allume, ça me fait :
Code: [Select]
Info: Solarus 1.6.0
Info: Opening quest 'C:/Users/Hpo/Desktop/The legend of Zelda Hyrule Adventure'
Info: Sound volume: 100
Info: Music volume: 100
Info: Joypad support enabled: true
Info: 2D acceleration: yes
Info: Turbo mode: no
Info: Video mode: normal
Info: LuaJIT: yes (LuaJIT 2.0.3)
Info: Language: fr
Info: Lua console: yes
Info: Simulation started
Error: In on_started: scripts/menus/pause_submenu.lua:39: No value with key 'save_dialog.yes' in strings.dat for language 'fr'
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
Error: In on_finished: scripts/menus/pause_inventory.lua:84: attempt to call method 'get_hud' (a nil value)
Info: Simulation finished

pour l'inventaire, et pour le game-over, je redémarre juste...
Pourriez-vous m'aider, s'il vous plaît ?
En attente de votre réponse,
Lucifer
« Last Edit: January 31, 2018, 08:42:23 pm by Lucifer »

froggy77

  • Full Member
  • ***
  • Posts: 100
    • View Profile
Re: Menu de game-over + inventaire en 1.6
« Reply #1 on: January 14, 2018, 09:30:44 pm »
Cela va être difficile de t'aider sans voir le contenu des fichiers en question, si tu ne connais pas quelques bases du lua et si tu ne comprends pas les messages d'erreur qui sont pourtant dans un anglais assez simple.
Que veulent dire, selon toi, ces lignes d'erreur?
Quote
Error: In on_started: scripts/menus/pause_submenu.lua:39: No value with key 'save_dialog.yes' in strings.dat for language 'fr'
Error: In on_draw: scripts/menus/pause_submenu.lua:110: attempt to index field 'caption_text_2' (a nil value)
« Last Edit: January 14, 2018, 09:35:02 pm by froggy77 »

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1094
    • View Profile
Re: Menu de game-over + inventaire en 1.6
« Reply #2 on: January 14, 2018, 09:39:59 pm »
D'après le premier message d'erreur, je dirais que tu as oublié de mettre en place une langue.

sol.language.set_language("fr")

Finkatore

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Menu de game-over + inventaire en 1.6
« Reply #3 on: January 15, 2018, 11:29:20 am »
If I did not read it, I would not benefit from it.

Lucifer

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Mon site
Re: Menu de game-over + inventaire en 1.6
« Reply #4 on: January 15, 2018, 05:36:02 pm »
Maintenant, ça me fait ça :
Code: [Select]
Info: Solarus 1.6.0
Info: Opening quest 'C:/Users/Hpo/Desktop/The legend of Zelda Hyrule Adventure'
Info: Sound volume: 100
Info: Music volume: 100
Info: Joypad support enabled: true
Info: 2D acceleration: yes
Info: Turbo mode: no
Info: Video mode: normal
Info: LuaJIT: yes (LuaJIT 2.0.3)
Info: Language: fr
Info: Lua console: yes
Info: Simulation started
Info: Language: fr
Error: In on_started: scripts/menus/pause_submenu.lua:72: attempt to call method 'set_custom_command_effect' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to index field 'cursor_sprite' (a nil value)
Error: In on_finished: scripts/menus/pause_inventory.lua:84: attempt to call method 'get_hud' (a nil value)
Info: Simulation finished
pour l'inventaire, j'ai pris les ressources de zelda xd2

Lucifer

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Mon site
Re: Menu de game-over + inventaire en 1.6
« Reply #5 on: January 16, 2018, 05:23:17 pm »
Et maintenant, ça me fait
Code: [Select]
Error: In on_draw: scripts/menus/pause_inventory.lua:195: attempt to perform arithmetic on field 'cursor_column' (a nil value)En attente de votre réponse,
Merci
Lucifer

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1094
    • View Profile
Re: Menu de game-over + inventaire en 1.6
« Reply #6 on: January 25, 2018, 06:06:10 pm »
Comme a dit froggy77, tu nous donnes des messages d'erreurs puis d'autres sans donner le code. Ni ce qui a changé entre tes différents rapports d'erreurs.

Mais le message d'erreur est assez clair, il y a une variable cursor_column utilisée à la ligne 95 alors qu'elle n'est pas définie.


Lucifer

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Mon site
Re: Menu de game-over + inventaire en 1.6
« Reply #7 on: January 26, 2018, 01:04:54 pm »
Voici mon code :
Code: Lua
  1. local submenu = require("scripts/menus/pause_submenu")
  2. local inventory_submenu = submenu:new()
  3.  
  4. local item_names = {
  5.   "feather",
  6.   "bomb_counter",
  7.   "bow",
  8.   "lamp",
  9.   "pegasus_shoes",
  10.   "bottle_1",
  11.  
  12.   "hookshot",
  13.   "boomerang",
  14.   "fire_rod",
  15.   "glove",
  16.   "bottle_2",
  17.  
  18.   "flippers",
  19.   "bottle_3",
  20. }
  21.  
  22. function inventory_submenu:on_started()
  23.  
  24.   submenu.on_started(self)
  25.  
  26.   self.cursor_sprite = sol.sprite.create("menus/pause_cursor")
  27.   self.sprites = {}
  28.   self.counters = {}
  29.   self.captions = {}
  30.  
  31.   for k = 1, #item_names do
  32.     if item_names[k] ~= "" then
  33.       -- Get the item, its possession state and amount.
  34.       local item = self.game:get_item(item_names[k])
  35.       local variant = item:get_variant()
  36.  
  37.       if variant > 0 then
  38.         if item:has_amount() then
  39.           -- Show a counter in this case.
  40.           local amount = item:get_amount()
  41.           local maximum = item:get_max_amount()
  42.  
  43.           self.counters[k] = sol.text_surface.create{
  44.             horizontal_alignment = "center",
  45.             vertical_alignment = "top",
  46.             text = item:get_amount(),
  47.             font = (amount == maximum) and "green_digits" or "white_digits",
  48.           }
  49.         end
  50.  
  51.         -- Initialize the sprite and the caption string.
  52.         self.sprites[k] = sol.sprite.create("entities/items")
  53.         self.sprites[k]:set_animation(item_names[k])
  54.         self.sprites[k]:set_direction(variant - 1)
  55.       end
  56.     end
  57.   end
  58.  
  59.   -- Initialize the cursor
  60.   local index = self.game:get_value("pause_inventory_last_item_index") or 0
  61.   local cursor_row = math.floor(index / 7)
  62.   local cursor_column = index % 7
  63.   self:set_cursor_position(row, column)
  64. end
  65.  
  66. function inventory_submenu:on_finished()
  67.  
  68.   if submenu.on_finished then
  69.     submenu.on_finished(self)
  70.   end
  71.  
  72.   if self:is_assigning_item() then
  73.     self:finish_assigning_item()
  74.   end
  75.  
  76.   local hud = self.game:get_hud()
  77.   if hud ~= nil then
  78.     self.game:get_hud():set_item_icon_opacity(1, 255)
  79.     self.game:get_hud():set_item_icon_opacity(2, 255)
  80.   end
  81. end
  82.  
  83. function inventory_submenu:set_cursor_position(row, column)
  84.  
  85.   self.cursor_row = row
  86.   self.cursor_column = column
  87.  
  88.   local index = row * 7 + column
  89.   self.game:set_value("pause_inventory_last_item_index", index)
  90.  
  91.   -- Update the caption text and the action icon.
  92.   local item_name = item_names[index + 1]
  93.   local item = item_name and item_name ~= "" and self.game:get_item(item_name) or nil
  94.   local variant = item and item:get_variant() or 0
  95.  
  96.   local item_icon_opacity = 128
  97.   if variant > 0 then
  98.     self:set_caption("inventory.caption.item." .. item_name .. "." .. variant)
  99.     self.game:set_custom_command_effect("action", "info")
  100.     if item:is_assignable() then
  101.       item_icon_opacity = 255
  102.     end
  103.   else
  104.     self:set_caption(nil)
  105.     self.game:set_custom_command_effect("action", nil)
  106.   end
  107.   self.game:get_hud():set_item_icon_opacity(1, item_icon_opacity)
  108.   self.game:get_hud():set_item_icon_opacity(2, item_icon_opacity)
  109. end
  110.  
  111. function inventory_submenu:get_selected_index()
  112.  
  113.   return self.cursor_row * 7 + self.cursor_column
  114. end
  115.  
  116. function inventory_submenu:is_item_selected()
  117.  
  118.   local item_name = item_names[self:get_selected_index() + 1]
  119.   return self.game:get_item(item_name):get_variant() > 0
  120. end
  121.  
  122. function inventory_submenu:on_command_pressed(command)
  123.  
  124.   local handled = submenu.on_command_pressed(self, command)
  125.  
  126.   if not handled then
  127.  
  128.     if command == "action" then
  129.       if self.game:get_command_effect("action") == nil
  130.             and self.game:get_custom_command_effect("action") == "info" then
  131.         self:show_info_message()
  132.         handled = true
  133.       end
  134.  
  135.     elseif command == "item_1" then
  136.       if self:is_item_selected() then
  137.         self:assign_item(1)
  138.         handled = true
  139.       end
  140.  
  141.     elseif command == "item_2" then
  142.       if self:is_item_selected() then
  143.         self:assign_item(2)
  144.         handled = true
  145.       end
  146.  
  147.     elseif command == "left" then
  148.       if self.cursor_column == 0 then
  149.         self:previous_submenu()
  150.       else
  151.         sol.audio.play_sound("cursor")
  152.         self:set_cursor_position(self.cursor_row, self.cursor_column - 1)
  153.       end
  154.       handled = true
  155.  
  156.     elseif command == "right" then
  157.       if self.cursor_column == 6 then
  158.         self:next_submenu()
  159.       else
  160.         sol.audio.play_sound("cursor")
  161.         self:set_cursor_position(self.cursor_row, self.cursor_column + 1)
  162.       end
  163.       handled = true
  164.  
  165.     elseif command == "up" then
  166.       sol.audio.play_sound("cursor")
  167.       self:set_cursor_position((self.cursor_row + 3) % 4, self.cursor_column)
  168.       handled = true
  169.  
  170.     elseif command == "down" then
  171.       sol.audio.play_sound("cursor")
  172.       self:set_cursor_position((self.cursor_row + 1) % 4, self.cursor_column)
  173.       handled = true
  174.  
  175.     end
  176.   end
  177.  
  178.   return handled
  179. end
  180.  
  181. function inventory_submenu:on_draw(dst_surface)
  182.  
  183.   self:draw_background(dst_surface)
  184.   self:draw_caption(dst_surface)
  185.  
  186.  -- Draw the cursor.
  187.   self.cursor_sprite:draw(dst_surface, 64 + 32 * self.cursor_column, 77 + 32 * self.cursor_row)
  188.  
  189.   -- Draw each inventory item.
  190.   local y = 82
  191.   local k = 0
  192.  
  193.   for i = 0, 3 do
  194.     local x = 64
  195.  
  196.     for j = 0, 6 do
  197.       k = k + 1
  198.       if item_names[k] ~= nil and item_names[k] ~= "" then
  199.         local item = self.game:get_item(item_names[k])
  200.         if item:get_variant() > 0 then
  201.           -- The player has this item: draw it.
  202.           self.sprites[k]:draw(dst_surface, x, y)
  203.           if self.counters[k] ~= nil then
  204.             self.counters[k]:draw(dst_surface, x + 8, y)
  205.           end
  206.         end
  207.       end
  208.       x = x + 32
  209.     end
  210.     y = y + 32
  211.   end
  212.  
  213.   -- Draw the item being assigned if any.
  214.   if self:is_assigning_item() then
  215.     self.item_assigned_sprite:draw(dst_surface)
  216.   end
  217.  
  218.   self:draw_save_dialog_if_any(dst_surface)
  219. end
  220.  
  221. -- Shows a message describing the item currently selected.
  222. -- The player is supposed to have this item.
  223. function inventory_submenu:show_info_message()
  224.  
  225.   local item_name = item_names[self:get_selected_index() + 1]
  226.   local variant = self.game:get_item(item_name):get_variant()
  227.   local map = self.game:get_map()
  228.  
  229.   -- Position of the dialog (top or bottom).
  230.   if self.cursor_row >= 2 then
  231.     self.game:get_dialog_box():set_position("top")  -- Top of the screen.
  232.   else
  233.     self.game:get_dialog_box():set_position("bottom")  -- Bottom of the screen.
  234.   end
  235.  
  236.   self.game:set_custom_command_effect("action", nil)
  237.   self.game:set_custom_command_effect("attack", nil)
  238.   self.game:start_dialog("_item_description." .. item_name .. "." .. variant, function()
  239.     self.game:set_custom_command_effect("action", "info")
  240.     self.game:set_custom_command_effect("attack", "save")
  241.     self.game:get_dialog_box():set_position("auto")  -- Back to automatic position.
  242.   end)
  243.  
  244. end
  245.  
  246. -- Assigns the selected item to a slot (1 or 2).
  247. -- The operation does not take effect immediately: the item picture is thrown to
  248. -- its destination icon, then the assignment is done.
  249. -- Nothing is done if the item is not assignable.
  250. function inventory_submenu:assign_item(slot)
  251.  
  252.   local index = self:get_selected_index() + 1
  253.   local item_name = item_names[index]
  254.   local item = self.game:get_item(item_name)
  255.  
  256.   -- If this item is not assignable, do nothing.
  257.   if not item:is_assignable() then
  258.     return
  259.   end
  260.  
  261.   -- If another item is being assigned, finish it immediately.
  262.   if self:is_assigning_item() then
  263.     self:finish_assigning_item()
  264.   end
  265.  
  266.   -- Memorize this item.
  267.   self.item_assigned = item
  268.   self.item_assigned_sprite = sol.sprite.create("entities/items")
  269.   self.item_assigned_sprite:set_animation(item_name)
  270.   self.item_assigned_sprite:set_direction(item:get_variant() - 1)
  271.   self.item_assigned_destination = slot
  272.  
  273.   -- Play the sound.
  274.   sol.audio.play_sound("throw")
  275.  
  276.   -- Compute the movement.
  277.   local x1 = 60 + 32 * self.cursor_column
  278.   local y1 = 75 + 32 * self.cursor_row
  279.   local x2 = (slot == 1) and 20 or 72
  280.   local y2 = 46
  281.  
  282.   self.item_assigned_sprite:set_xy(x1, y1)
  283.   local movement = sol.movement.create("target")
  284.   movement:set_target(x2, y2)
  285.   movement:set_speed(500)
  286.   movement:start(self.item_assigned_sprite, function()
  287.     self:finish_assigning_item()
  288.   end)
  289. end
  290.  
  291. -- Returns whether an item is currently being thrown to an icon.
  292. function inventory_submenu:is_assigning_item()
  293.   return self.item_assigned_sprite ~= nil
  294. end
  295.  
  296. -- Stops assigning the item right now.
  297. -- This function is called when we want to assign the item without
  298. -- waiting for its throwing movement to end, for example when the inventory submenu
  299. -- is being closed.
  300. function inventory_submenu:finish_assigning_item()
  301.  
  302.   -- If the item to assign is already assigned to the other icon, switch both items.
  303.   local slot = self.item_assigned_destination
  304.   local current_item = self.game:get_item_assigned(slot)
  305.   local other_item = self.game:get_item_assigned(3 - slot)
  306.  
  307.   if other_item == self.item_assigned then
  308.     self.game:set_item_assigned(3 - slot, current_item)
  309.   end
  310.   self.game:set_item_assigned(slot, self.item_assigned)
  311.  
  312.   self.item_assigned_sprite:stop_movement()
  313.   self.item_assigned_sprite = nil
  314.   self.item_assigned = nil
  315. end
  316.  
  317. return inventory_submenu
  318.  
  319.  

comment puis-je faire pour la définir ?

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1094
    • View Profile
Re: Menu de game-over + inventaire en 1.6
« Reply #8 on: January 26, 2018, 03:00:23 pm »
D'où vient ce script exactement ?

Lucifer

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Mon site
Re: Menu de game-over + inventaire en 1.6
« Reply #9 on: January 26, 2018, 03:40:43 pm »
Zelda XD2

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1094
    • View Profile
Re: Menu de game-over + inventaire en 1.6
« Reply #10 on: January 26, 2018, 04:22:08 pm »
Zelda XD2
Peut-être mais avec des mauvais changements alors.

Voici ton code :
Code: Lua
  1. ...
  2.   -- Initialize the cursor
  3.   local index = self.game:get_value("pause_inventory_last_item_index") or 0
  4.   local cursor_row = math.floor(index / 7)
  5.   local cursor_column = index % 7
  6.   self:set_cursor_position(row, column)
  7. ...
  8.  

Et celui de Zelda XD2 :
(https://github.com/solarus-games/zelda-xd2-mercuris-chess/blob/dev/data/scripts/menus/pause_inventory.lua#L69)
Code: Lua
  1. ...
  2.   -- Initialize the cursor
  3.   local index = self.game:get_value("pause_inventory_last_item_index") or 0
  4.   local row = math.floor(index / 7)
  5.   local column = index % 7
  6.   self:set_cursor_position(row, column)
  7. ...
  8.  

Le message d'erreur pointe vers cet endroit. Il y a au moins cette différence qui explique que ton curseur soit mal initialisé.

Lucifer

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Mon site
Re: Menu de game-over + inventaire en 1.6
« Reply #11 on: January 26, 2018, 04:43:25 pm »
quand je lance zelda xd2 qui a pourtant le même code, ça fonctionne, or si j'allume l'inventaire sur ma partie, ça ne marche pas

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1094
    • View Profile
Re: Menu de game-over + inventaire en 1.6
« Reply #12 on: January 26, 2018, 05:11:39 pm »
Je viens de te pointer l'endroit qui montre que ce n'est pas le même code.

Lucifer

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Mon site
Re: Menu de game-over + inventaire en 1.6
« Reply #13 on: January 26, 2018, 05:14:22 pm »
j'ai remis le code de zelda xd2, mais ça ne marche toujours pas...

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1094
    • View Profile
Re: Menu de game-over + inventaire en 1.6
« Reply #14 on: January 26, 2018, 05:29:29 pm »
Encore une fois, il va falloir quelque chose de plus précis que "ça ne marche pas"