summaryrefslogtreecommitdiffstats
path: root/src/scripting
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-05-03 12:56:16 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-05-03 12:56:29 +0200
commiteb9fdd6852fced4ca9125b93585b95eb319dce18 (patch)
tree840aab10aedcdb1f67064310995d1f767e0b6a5e /src/scripting
parent0261eb73e5588f5732aef5df753311d488c45d06 (diff)
downloadmanaserv-eb9fdd6852fced4ca9125b93585b95eb319dce18.tar.gz
manaserv-eb9fdd6852fced4ca9125b93585b95eb319dce18.tar.xz
manaserv-eb9fdd6852fced4ca9125b93585b95eb319dce18.zip
Made member function tables available as a globals
This way the scripts can add or replace existing member functions, which can be useful. As demonstration chr_money and chr_money_change are now added as Entity.money and Entity.change_money. Also fixed the banker to use ask_number instead of ask_integer (I had decided to rename this and apparently forgot the banker). Mantis-issue: 503 Reviewed-by: Ablu
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/luautil.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/scripting/luautil.h b/src/scripting/luautil.h
index 26ed33c..f2b7689 100644
--- a/src/scripting/luautil.h
+++ b/src/scripting/luautil.h
@@ -106,6 +106,11 @@ public:
#else
luaL_setfuncs(s, members, 0);
#endif
+
+ // Make the functions table available as a global
+ lua_pushvalue(s, -1); // metatable, "__index", {}, {}
+ lua_setglobal(s, mTypeName); // metatable, "__index", {}
+
lua_rawset(s, -3); // metatable
lua_pop(s, 1); // -empty-
}