# Here's where I define my lua function...
#define MY_LUA_FUNCS
[lua]
code = <<
beastGoldValues = {3, 5, 10, 15, 25, 50, 100, 200}
function beastDie()
local e = wesnoth.current.event_context
local team = wesnoth.get_side(wesnoth.get_units({ x = e.x2, y = e.y2 })[1].side)
local beastie = wesnoth.get_units({ x = e.x1, y = e.y1 })[1]
local award = beastGoldValues[wesnoth.get_unit_type(beastie.type).level + 1]
team.gold = team.gold + award
wesnoth.float_label(e.x2, e.y2, string.format("<span color='#ffff00'>+%d Gold</span>", award))
end
--[[ lots of other stuff.... ]]--
>>
[/lua]
#enddef
# I'm declaring my Lua functions here...
[event]
name=prestart
{MY_LUA_FUNCS}
# other stuff....
[/event]
# this is where I call it from...
[event]
name=die
first_time_only=no
[filter]
side=5
[/filter]
[sound]
name=gold.ogg
[/sound]
[lua]
code = << beastDie() >>
[/lua]
[/event]
This is my error:
20110416 21:06:15 error scripting/lua: [string " beastDie() "]:1: attempt to call global 'beastDie' (a nil value)
stack traceback:
[string " beastDie() "]:1: in main chunk