diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-07-13 16:20:26 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-07-13 19:20:03 +0200 |
commit | 907b740c17a69a487126c63f6ff917d494a25a1f (patch) | |
tree | 1271e100408160660ed27fa01dbce6e824b49e60 /scripts/lua/libmana.lua | |
parent | 89847fcbb1befb5b6c31fc42fb3e56d3a2fd6654 (diff) | |
download | manaserv-907b740c17a69a487126c63f6ff917d494a25a1f.tar.gz manaserv-907b740c17a69a487126c63f6ff917d494a25a1f.tar.bz2 manaserv-907b740c17a69a487126c63f6ff917d494a25a1f.tar.xz manaserv-907b740c17a69a487126c63f6ff917d494a25a1f.zip |
Fixed the atinit function
Previously each map had its own scope. They got merged now but the atinit
function was forgotten to adapt.
Diffstat (limited to 'scripts/lua/libmana.lua')
-rw-r--r-- | scripts/lua/libmana.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scripts/lua/libmana.lua b/scripts/lua/libmana.lua index d133e574..5d3164d9 100644 --- a/scripts/lua/libmana.lua +++ b/scripts/lua/libmana.lua @@ -89,7 +89,9 @@ end -- Registers a function so that is is executed during map initialization. function atinit(f) - init_fun[#init_fun + 1] = f + local map_id = get_map_id() + init_fun[map_id] = init_fun[map_id] or {} + table.insert(init_fun[map_id], f) end -- Called by the game for creating NPCs embedded into maps. @@ -105,10 +107,12 @@ end -- Called during map initialization, for each map. -- Executes all the functions registered by atinit. local function map_initialize() - for i,f in ipairs(init_fun) do + local functions = init_fun[get_map_id()] + if not functions then return end + for i,f in ipairs(functions) do f() end - init_fun = {} + init_fun[get_map_id()] = nil end |