diff options
| author | Alexander Pickering <alex@cogarr.net> | 2018-06-28 16:05:26 -0600 |
|---|---|---|
| committer | Alexander Pickering <alex@cogarr.net> | 2018-06-28 16:05:26 -0600 |
| commit | ef25a513437196a3ea9ee45e6e03565eb86067d2 (patch) | |
| tree | acd43d214f9a7ec96e7fcd66097fd13593dd8f38 /src/shared/lua_api/common.c | |
| parent | 2260a1dda8693664c77a03781ae07fbb5f0ea8a0 (diff) | |
| download | brokengine-ef25a513437196a3ea9ee45e6e03565eb86067d2.tar.gz brokengine-ef25a513437196a3ea9ee45e6e03565eb86067d2.tar.bz2 brokengine-ef25a513437196a3ea9ee45e6e03565eb86067d2.zip | |
Simplified makefile
Made makefile much simpiler, added option to build dynamically with
DEBUG=true
Diffstat (limited to 'src/shared/lua_api/common.c')
| -rw-r--r-- | src/shared/lua_api/common.c | 205 |
1 files changed, 0 insertions, 205 deletions
diff --git a/src/shared/lua_api/common.c b/src/shared/lua_api/common.c deleted file mode 100644 index 2eeee11..0000000 --- a/src/shared/lua_api/common.c +++ /dev/null @@ -1,205 +0,0 @@ - -extern "C" { - #include <lua.h> - #include <lauxlib.h> - #include <lualib.h> -} - -#include "common.h" - -//Expose things to the lua state -void loadLLibs(lua_State* L){ - - lua_pushcfunction(L,luaopen_base); - lua_pushliteral(L,""); - lua_call(L,1,0); - - lua_pushcfunction(L,luaopen_table); - lua_pushliteral(L,LUA_TABLIBNAME); - lua_call(L,1,0); - - lua_pushcfunction(L,luaopen_string); - lua_pushliteral(L,LUA_STRLIBNAME); - lua_call(L,1,0); - - lua_pushcfunction(L,luaopen_math); - lua_pushliteral(L,LUA_MATHLIBNAME); - lua_call(L,1,0); - - lua_pushcfunction(L,luaopen_string); - lua_pushliteral(L,LUA_STRLIBNAME); - lua_call(L,1,0); - - /* - lua_pushcfunction(L,luaopen_string); - lua_pushliteral(L,LUA_STRLIBNAME); - lua_call(L,1,0); - */ -} - - -int pushvector3i(lua_State* L,long a,long b,long c){ - lua_newtable(L);//{} - - lua_pushinteger(L,1);//{},1 - lua_pushinteger(L,a);//{},1,a - lua_settable(L,-3);//{} - - lua_pushinteger(L,2);//{},2 - lua_pushinteger(L,b);//{},2,b - lua_settable(L,-3);//{} - - lua_pushinteger(L,3);//{},3 - lua_pushinteger(L,c);//{},3,c - lua_settable(L,-3);//{} - - return 1; -} -int pushvector3d(lua_State* L,double a,double b,double c){ - lua_newtable(L);//{} - - lua_pushinteger(L,1);//{},1 - lua_pushnumber(L,a);//{},1,a - lua_settable(L,-3);//{} - - lua_pushinteger(L,2);//{},2 - lua_pushnumber(L,b);//{},2,b - lua_settable(L,-3);//{} - - lua_pushinteger(L,3);//{},3 - lua_pushnumber(L,c);//{},3,c - lua_settable(L,-3);//{} - - return 1; -} -int pushvector2i(lua_State* L, long a, long b){ - lua_newtable(L); - - lua_pushinteger(L,1); - lua_pushinteger(L,a); - lua_settable(L,-3); - - lua_pushinteger(L,2); - lua_pushinteger(L,b); - lua_settable(L,-3); - - return 1; -} - -int popvector4i(lua_State* L,long* a,long* b,long* c, long* d){ - lua_pushinteger(L,1);//{v4},1 - lua_gettable(L,-2);//{v4},v4[1] - *a = lua_tointeger(L,-1);//{v4},v4[1] - lua_pop(L,1);//{v4} - - lua_pushinteger(L,2);//{v4},2 - lua_gettable(L,-2);//{v4},v4[2] - *b = lua_tointeger(L,-1);//{v4},v4[2] - lua_pop(L,1);//{v4} - - lua_pushinteger(L,3);//{v4},3 - lua_gettable(L,-2);//{v4},v4[3] - *c = lua_tointeger(L,-1);//{v4},v4[3] - lua_pop(L,1);//{v4} - - lua_pushinteger(L,4);//{v4},3 - lua_gettable(L,-2);//{v4},v4[3] - *d = lua_tointeger(L,-1);//{v4},v4[3] - lua_pop(L,1);//{v4} - - lua_pop(L,1);// - return 0; -} - -int popvector3i(lua_State* L,long* a,long* b,long* c){//{v3} - lua_pushinteger(L,1);//{v3},1 - lua_gettable(L,-2);//{v3},v3[1] - *a = lua_tointeger(L,-1);//{v3},v3[1] - lua_pop(L,1);//{v3} - - lua_pushinteger(L,2);//{v3},2 - lua_gettable(L,-2);//{v3},v3[2] - *b = lua_tointeger(L,-1);//{v3},v3[2] - lua_pop(L,1);//{v3} - - lua_pushinteger(L,3);//{v3},3 - lua_gettable(L,-2);//{v3},v3[3] - *c = lua_tointeger(L,-1);//{v3},v3[3] - lua_pop(L,1);//{v3} - - lua_pop(L,1);// - return 0; -} - - - -int popvector3d(lua_State* L,double* a,double* b,double* c){ - lua_pushinteger(L,1); - lua_gettable(L,-2); - *a = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L,2); - lua_gettable(L,-2); - *b = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L,3); - lua_gettable(L,-2); - *c = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pop(L,1); - return 0; -} - -int popvector4d(lua_State* L, double *a, double *b, double *c, double *d){ - lua_pushinteger(L,1);//{a,b,c,d},1 - lua_gettable(L,-2);//{a,b,c,d},a - *a = lua_tonumber(L,-1);//{a,b,c,d},a - lua_pop(L,1);//{a,b,c,d} - - lua_pushinteger(L,2); - lua_gettable(L,-2); - *b = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L,3); - lua_gettable(L,-2); - *c = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L,4); - lua_gettable(L,-2); - *d = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pop(L,1); - return 0; -} - -//{{sx,sy},{ex,ey}} -int poprecti(lua_State* L, long *sx, long *sy, long *ex, long *ey){ - lua_pushnumber(L,1); - lua_gettable(L,-2); - popvector2i(L,sx,sy); - lua_pushnumber(L,2); - lua_gettable(L,-2); - popvector2i(L,ex,ey); - lua_pop(L,1); - return 0; -} - -int popvector2i(lua_State* L, long* a, long* b){ - lua_pushinteger(L,1); - lua_gettable(L,-2); - *a = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L,2); - lua_gettable(L,-2); - *b = lua_tonumber(L,-1); - lua_pop(L,2); - - return 0; -} |
