Author Topic: Cryptic error  (Read 3134 times)

wrightmat

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Cryptic error
« on: February 04, 2014, 05:17:40 am »
I was hoping I'd be able to get some help decrypting this error, because I don't understand why I'm getting one. I'm getting the following when I run my game:
Error: Failed to load script 'maps/1': [string "maps/1.lua"]:14: malformed number near '.0.shop_mushroom_done_dialog_finished'

The script around that line is:
Code: [Select]
  if destination == "main_entrance_shop" and game:get_value("i2021") == 10 then
    game:start_dialog("crista.0.shop_mushroom.7", crista.0.shop_mushroom_done_dialog_finished)
  end

And the function being called:
Code: [Select]
local function crista.0.shop_mushroom_done_dialog_finished()
  game:set_value("i3001", game:get_value("i3001")+1)
  hero:start_treasure("trading", 2)
end

I'm guessing it's related to changes in 1.2.0, since I don't recall having an error when running an earlier version.
« Last Edit: February 04, 2014, 05:35:33 am by wrightmat »

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1176
    • View Profile
Re: Cryptic error
« Reply #1 on: February 04, 2014, 07:51:02 am »
There is a syntax error in your Lua code.
crista.0.shop_mushroom_done_dialog_finished is not a valid expression, you cannot index a table (crista) with 0 like this.
Also, the function you declare is not local, it is in a table because there are dots in the name.

You can do a local function like this:

Code: [Select]
local function shop_mushroom_done_dialog_finished()
  game:set_value("i3001", game:get_value("i3001")+1)
  hero:start_treasure("trading", 2)
end

if destination == main_entrance_shop and game:get_value("i2021") == 10 then
  game:start_dialog("crista.0.shop_mushroom.7", shop_mushroom_done_dialog_finished)
end

But there is even a simpler way if the function is only used there:

Code: [Select]
if destination == main_entrance_shop and game:get_value("i2021") == 10 then
  game:start_dialog("crista.0.shop_mushroom.7", function()
    game:set_value("i3001", game:get_value("i3001")+1)
    hero:start_treasure("trading", 2)
  end)
end

Note: I removed the quotes around main_entrance, because since Solarus 1.0, the destination is a real entity type, not a string with the destination name.

wrightmat

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: Cryptic error
« Reply #2 on: February 05, 2014, 05:38:16 pm »
That worked wonderfully - thank you! I'm slowly getting my scripts converted over to the new syntax, and I'm finding it to be much more concise and logical. Great job and thanks again for everything you've done with this engine!


Another oddity I encountered, except this one is graphical.



When I enter a map larger than the current screen, and move the character out of the initial drawing region, it appears that all of those tiles are never drawn (see above). The entities and dynamic tiles appear to be, but not the static tiles. If I leave and re-enter this map, say in a different area, a new region is drawn but I can once again move out of the drawn region.




Here's an image from the editor of what the area should look like,


I'm running Solarus 1.2.0 with 2D acceleration on (even stranger, if I run with acceleration off, I get no display at all - only a black screen) on Ubuntu linux 13.10.

wrightmat

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: Cryptic error
« Reply #3 on: February 05, 2014, 05:41:41 pm »
Confirmed that it happens with zsdx as well. Is there something wrong on my system? Is there a way I can debug this?

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1176
    • View Profile
Re: Cryptic error
« Reply #4 on: February 05, 2014, 07:01:01 pm »
I had exactly the same problem. It is a bug in SDL 2.0.0, fixed in SDL 2.0.1. Unfortunately, Ubuntu 13.10 only provides SDL 2.0.0 :)
Debian provides SDL 2.0.1, so you can download the debian .deb packages:
http://packages.debian.org/jessie/libsdl2-2.0-0
and then
http://packages.debian.org/jessie/libsdl2-dev
« Last Edit: February 05, 2014, 07:21:18 pm by Christopho »

wrightmat

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: Cryptic error
« Reply #5 on: February 05, 2014, 08:38:56 pm »
Updating SDL worked perfectly! You are a genius, thanks!