diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-11 18:16:16 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-11 19:27:32 +0100 |
commit | 5ff34fd2458dff28d664c90fb93f455231f8633c (patch) | |
tree | 533151e5f3002c1e24ce4d44e5cd32c66c026b51 /scripts | |
parent | b822dcee52d15d41c4186a250e73b85b16c9dc39 (diff) | |
download | manaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.tar.gz manaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.tar.bz2 manaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.tar.xz manaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.zip |
Register Lua script API functions into the global namespace
Scripts mostly execute the Mana script API, and it seems like just
unnecessary verbosity to refer to the 'mana' table all the time. This table
no longer exists now.
Reviewed-by: Erik Schilling
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lua/libmana.lua | 34 | ||||
-rw-r--r-- | scripts/lua/npclib.lua | 18 |
2 files changed, 26 insertions, 26 deletions
diff --git a/scripts/lua/libmana.lua b/scripts/lua/libmana.lua index e76e9ec0..e9c89212 100644 --- a/scripts/lua/libmana.lua +++ b/scripts/lua/libmana.lua @@ -61,7 +61,7 @@ end local function create_npc_delayed(name, id, gender, x, y) -- Bind the name to a local variable first, as it will be reused. local h = npc_handler - atinit(function() mana.npc_create(name, id, gender, x, y, h) end) + atinit(function() npc_create(name, id, gender, x, y, h) end) npc_handler = nil end @@ -120,7 +120,7 @@ local onworldvar_functs = {} local function on_mapvar_callback(key, value) local functs = onmapvar_functs[key] - local mapid = mana.get_map_id() + local mapid = get_map_id() for func, map in pairs(functs) do if map == mapid then func(key, value) @@ -138,15 +138,15 @@ end function on_mapvar_changed(key, funct) if not onmapvar_functs[key] then onmapvar_functs[key] = {} - mana.on_mapvar_changed(key, on_mapvar_callback) + on_mapvar_changed(key, on_mapvar_callback) end - onmapvar_functs[key][funct] = mana.get_map_id() + onmapvar_functs[key][funct] = get_map_id() end function on_worldvar_changed(key, funct) if not onworldvar_functs[key] then onworldvar_functs[key] = {} - mana.on_worldvar_changed(key, on_worldvar_callback) + on_worldvar_changed(key, on_worldvar_callback) end onworldvar_functs[key][funct] = true end @@ -170,7 +170,7 @@ function on_death(being, funct) ondeath_functs[being] = {} end table.insert(ondeath_functs[being], funct) - mana.being_register(being) + being_register(being) end -- requests the gameserver to notify the script engine when the being @@ -180,7 +180,7 @@ function on_remove(being, funct) onremove_functs[being] = {} end table.insert(onremove_functs[being], funct) - mana.being_register(being) + being_register(being) end -- Registered as callback for when a registered being dies. @@ -206,22 +206,22 @@ end -- Below are some convenience methods added to the engine API -mana.chr_money_change = function(ch, amount) - mana.being_set_base_attribute( +chr_money_change = function(ch, amount) + being_set_base_attribute( ch, ATTR_GP, - mana.being_get_base_attribute(ch, ATTR_GP) + amount) + being_get_base_attribute(ch, ATTR_GP) + amount) end -mana.chr_money = function(ch) - return mana.being_get_base_attribute(ch, ATTR_GP) +chr_money = function(ch) + return being_get_base_attribute(ch, ATTR_GP) end -- Register callbacks -mana.on_update(update) +on_update(update) -mana.on_create_npc_delayed(create_npc_delayed) -mana.on_map_initialize(map_initialize) +on_create_npc_delayed(create_npc_delayed) +on_map_initialize(map_initialize) -mana.on_being_death(death_notification) -mana.on_being_remove(remove_notification) +on_being_death(death_notification) +on_being_remove(remove_notification) diff --git a/scripts/lua/npclib.lua b/scripts/lua/npclib.lua index 9edfcbd9..48e53769 100644 --- a/scripts/lua/npclib.lua +++ b/scripts/lua/npclib.lua @@ -31,8 +31,8 @@ local wasmall_starty = {} function walkaround_small(npc) if not wasmall_timer[npc] then wasmall_timer[npc] = 1 - wasmall_startx[npc] = mana.posX(npc) - wasmall_starty[npc] = mana.posY(npc) + wasmall_startx[npc] = posX(npc) + wasmall_starty[npc] = posY(npc) end wasmall_timer[npc] = wasmall_timer[npc] + 1 @@ -41,7 +41,7 @@ function walkaround_small(npc) wasmall_timer[npc] = math.random(1, 10) local x = math.random(-32, 32) + wasmall_startx[npc] local y = math.random(-32, 32) + wasmall_starty[npc] - mana.being_walk(npc, x, y, 2) + being_walk(npc, x, y, 2) end end @@ -58,8 +58,8 @@ local wawide_starty = {} function walkaround_wide(npc) if not wawide_timer[npc] then wawide_timer[npc] = 1 - wawide_startx[npc] = mana.posX(npc) - wawide_starty[npc] = mana.posY(npc) + wawide_startx[npc] = posX(npc) + wawide_starty[npc] = posY(npc) end wawide_timer[npc] = wawide_timer[npc] + 1 @@ -68,7 +68,7 @@ function walkaround_wide(npc) wawide_timer[npc] = math.random(1, 10) local x = math.random(-128, 128) + wawide_startx[npc] local y = math.random(-128, 128) + wawide_starty[npc] - mana.being_walk(npc, x, y, 2) + being_walk(npc, x, y, 2) end end @@ -88,9 +88,9 @@ function walkaround_map(npc) if wam_timer[npc] == 50 then wam_timer[npc] = math.random(1, 10) - local x = math.random(-128, 128) + mana.posX(npc) - local y = math.random(-128, 128) + mana.posY(npc) - mana.being_walk(npc, x, y, 2) + local x = math.random(-128, 128) + posX(npc) + local y = math.random(-128, 128) + posY(npc) + being_walk(npc, x, y, 2) end end |