From eb9fdd6852fced4ca9125b93585b95eb319dce18 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Fri, 3 May 2013 12:56:16 +0200 Subject: 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 --- src/scripting/luautil.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/scripting') 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- } -- cgit