summaryrefslogtreecommitdiff
path: root/src/scripting/lua.cpp
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2012-03-10 23:31:32 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2012-03-11 10:16:35 +0100
commit520705579d6a68cf6908275026eef2edee0758af (patch)
tree2d37eb5e28a1f6d95bac4094a613f054c08c55b2 /src/scripting/lua.cpp
parent78c912fb4007c3e5f0b43de02646772acb21ecf2 (diff)
downloadmanaserv-520705579d6a68cf6908275026eef2edee0758af.tar.gz
manaserv-520705579d6a68cf6908275026eef2edee0758af.tar.bz2
manaserv-520705579d6a68cf6908275026eef2edee0758af.tar.xz
manaserv-520705579d6a68cf6908275026eef2edee0758af.zip
Added callbacks for map/worldvar changes
Reviewed-by: bjorn.
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r--src/scripting/lua.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 5053070a..a416771f 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -161,6 +161,26 @@ static int on_get_special_recharge_cost(lua_State *s)
return 0;
}
+static int on_mapvar_changed(lua_State *s)
+{
+ const char *key = luaL_checkstring(s, 1);
+ luaL_checktype(s, 2, LUA_TFUNCTION);
+ luaL_argcheck(s, key[0] != 0, 2, "empty variable name");
+ MapComposite *m = checkCurrentMap(s);
+ m->setMapVariableCallback(key, getScript(s));
+ return 0;
+}
+
+static int on_worldvar_changed(lua_State *s)
+{
+ const char *key = luaL_checkstring(s, 1);
+ luaL_checktype(s, 2, LUA_TFUNCTION);
+ luaL_argcheck(s, key[0] != 0, 2, "empty variable name");
+ MapComposite *m = checkCurrentMap(s);
+ m->setWorldVariableCallback(key, getScript(s));
+ return 0;
+}
+
static int get_item_class(lua_State *s)
{
LuaItemClass::push(s, checkItemClass(s, 1));
@@ -2139,6 +2159,8 @@ LuaScript::LuaScript():
{ "on_craft", &on_craft },
{ "on_use_special", &on_use_special },
{ "on_get_special_recharge_cost", &on_get_special_recharge_cost },
+ { "on_mapvar_changed", &on_mapvar_changed },
+ { "on_worldvar_changed", &on_worldvar_changed },
{ "get_item_class", &get_item_class },
{ "get_monster_class", &get_monster_class },
{ "get_status_effect", &get_status_effect },