Author Topic: [1.3] Bug SubMenu  (Read 1351 times)

Yruama

  • Newbie
  • *
  • Posts: 24
    • View Profile
[1.3] Bug SubMenu
« on: November 20, 2014, 01:32:27 am »
Hi,

It's me again ...  :-[

Now i want to create a menu for the items. I Dowload your package : https://www.youtube.com/watch?v=oh6I4yLUQ3E&index=28&list=PLzJ4jb-Y0ufySXw9_E-hJzmzSh-PYCyG2
I modified the file "Game_Manager" like you, but when i start the gamehttp://forum.solarus-games.org/Themes/default/images/bbc/table.gif and i press "D" i have some error :

Code: [Select]
Error: In on_started: [string "scripts/menus/pause_submenu.lua"]:19: attempt to call field 'get_dialog_font' (a nil value)
Error: In on_draw: [string "scripts/menus/pause_submenu.lua"]:96: attempt to index field 'caption_text_2' (a nil value)

Before doing that, I 've changed a line (in Pause Menu Line 78) :

Code: [Select]
   local line1, line2 = text:match("([^$]+)\$(.*)") to
Code: [Select]
   local line1, line2 = text:match("([^$]+)$(.*)")

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1172
    • View Profile
Re: [1.3] Bug SubMenu
« Reply #1 on: November 20, 2014, 08:57:35 am »
Hi!
Sorry about these outdated tutorials. I have started to make new ones with latest versions, but it takes time :)

Before doing that, I 've changed a line (in Pause Menu Line 78) :

Code: [Select]
   local line1, line2 = text:match("([^$]+)\$(.*)") to
Code: [Select]
   local line1, line2 = text:match("([^$]+)$(.*)")
The correct line is
Code: [Select]
    local line1, line2 = text:match("([^$]+)%$(.*)")The goal here is to escape the $ character in the pattern. In Lua, the escape character in patterns is % and not \. (In worked before by luck because vanilla Lua allows \ too even if it is incorrect. LuaJIT does not.)

Anyway, that should fix your second error (field 'caption_text_2' being nil).

Code: [Select]
Error: In on_started: [string "scripts/menus/pause_submenu.lua"]:19: attempt to call field 'get_dialog_font' (a nil value)

In the resources to download with the tutorial, main.lua defines two new functions sol.language.get_dialog_font() and sol.language.get_menu_font(). You probably forgot to copy them.

Yruama

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: [1.3] Bug SubMenu
« Reply #2 on: November 20, 2014, 12:12:48 pm »
Oh i love you :D.

I try to find a solution in yout game, but it's ... hard. You have more files than in your tutorial :D