From 43be4b75f5a0f0e44b12b6414007b849838ad6f3 Mon Sep 17 00:00:00 2001 From: nveid Date: Tue, 28 Dec 2010 05:25:04 +0000 Subject: [PATCH] LUA update 2.. Including initial SWIG input file --- src/lua.c | 17 +++++++++-------- src/mushlua.i | 12 ++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 src/mushlua.i 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; + -- 2.30.2