Cryptic error

Started by wizard_wizzle (aka ZeldaHistorian), February 04, 2014, 05:17:40 AM

Previous topic - Next topic
February 04, 2014, 05:17:40 AM Last Edit: February 04, 2014, 05:35:33 AM by wrightmat
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:
  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:
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.

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:


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:


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.

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.

Confirmed that it happens with zsdx as well. Is there something wrong on my system? Is there a way I can debug this?

February 05, 2014, 07:01:01 PM #4 Last Edit: February 05, 2014, 07:21:18 PM by Christopho
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

Updating SDL worked perfectly! You are a genius, thanks!