(fixed) moneybox
Posted: Thu Nov 22, 2007 2:35 am
The code for the money box is faulty. I mean, it works as long as the item is called "moneybox" in objects.lua, something that ROOT_NAME tries to take care of, unsuccesfully. Change "moneybox" to "banana" in dsb_import_arch("moneybox.lua", "moneybox") (and the dsb_spawn in dungeon.lua, of course) and it all goes down.
I've found one fix:
in moneybox.lua, change obj[ROOT_NAME] to the following:
You can also change gfx.moneybox.inside to gfx[ROOT_NAME .. "_inside"] in function moneybox_subrenderer.
This will let the moneybox compile even if the dungeon designer happened to call the "moneybox" something else. Unfortunately, DSB will still crash when you pick up the moneybox as ROOT_NAME is not saved past compilation and that modified line in function moneybox_subrenderer is now trying to concatenate a nil value, something that Lua looks down upon.
I have not yet found a fix for that.
I've found one fix:
in moneybox.lua, change obj[ROOT_NAME] to the following:
Code: Select all
obj[ROOT_NAME] = {
name="MONEY BOX",
type="THING",
class="CONTAINER",
mass=11,
icon=gfx[ROOT_NAME .. "_icon"], -- Change here
alt_icon=gfx[ROOT_NAME .. "_alticon"], -- and here
dungeon=gfx[ROOT_NAME], -- and here
msg_handler = {
[M_MONEYBOX] = moneybox_click,
[M_DESTROY] = self_destruct
},
zone_obj = {
"gem_blue",
"gem_orange",
"gem_green",
"coin_gold",
"coin_silver",
"coin_copper"
},
subrenderer = moneybox_subrenderer,
to_r_hand = alticon,
from_r_hand = normicon,
max_throw_power=30
}
This will let the moneybox compile even if the dungeon designer happened to call the "moneybox" something else. Unfortunately, DSB will still crash when you pick up the moneybox as ROOT_NAME is not saved past compilation and that modified line in function moneybox_subrenderer is now trying to concatenate a nil value, something that Lua looks down upon.
I have not yet found a fix for that.