From: nveid Date: Tue, 28 Dec 2010 05:25:04 +0000 (+0000) Subject: LUA update 2.. Including initial SWIG input file X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=43be4b75f5a0f0e44b12b6414007b849838ad6f3;p=cobramush.git LUA update 2.. Including initial SWIG input file --- diff --git a/src/lua.c b/src/lua.c index 5d11b9d..3600c20 100644 --- a/src/lua.c +++ b/src/lua.c @@ -15,6 +15,7 @@ #include "lualib.h" #include "lauxlib.c" +extern void luaopen_cobra(lua_State *); static lua_State *mush_lua_env = NULL; static lua_CFunction mlua_notify(lua_State *); void mlua_test(dbref); @@ -29,7 +30,10 @@ void mush_lua_start() { mush_lua_env = lua_open(); + /* Load MUSH Library */ luaL_register(mush_lua_env, "mush", mlua_lib); + /* Load Cobra SWIG Wrappers */ + luaopen_cobra(mush_lua_env); luaL_openlibs(mush_lua_env); } @@ -48,9 +52,8 @@ void mlua_test(dbref enactor) { s = luaL_loadfile(mush_lua_env, "lua/test.lua"); - if(s==0) { + if(s==0) s = lua_pcall(mush_lua_env, 0, LUA_MULTRET, 0); - } if(s != 0) notify_format(enactor, "Lua Error: %s\n", lua_tostring(mush_lua_env, -1)); @@ -70,12 +73,10 @@ static lua_CFunction mlua_notify(lua_State *L) { } else if(!lua_isnumber(L, 1)) { lua_pushstring(L, "first argument must be an integer"); lua_error(L); - } else { - - lua_concat(L, nargs-1); - obj = lua_tonumber(L, 1); - - notify(obj, lua_tostring(L, -1) ); + } else { + lua_concat(L, nargs-1); + obj = lua_tonumber(L, 1); + notify(obj, lua_tostring(L, -1) ); } } diff --git a/src/mushlua.i b/src/mushlua.i new file mode 100644 index 0000000..b9ae76f --- /dev/null +++ b/src/mushlua.i @@ -0,0 +1,12 @@ +%module cobra %{ +#include "conf.h" +#include "externs.h" +#include "dbdefs.h" + +extern struct db_stat_info current_state; +%} +void do_reboot(int player, int flag); +%mutable; +extern int shutdown_flag; +extern struct db_stat_info current_state; +