aboutsummaryrefslogtreecommitdiff
path: root/src/shared/lua_api/common.c
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-05-28 17:07:04 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2018-05-28 17:07:04 -0400
commit06d3e8182d018ca613f177f6ff7a3bbb6494cc79 (patch)
tree18289e9d48c03cb3910e5fbe27ffd18c6b81eb53 /src/shared/lua_api/common.c
parent5fc253ce728c6e078886e092376c2e0f0320ebd9 (diff)
downloadbrokengine-06d3e8182d018ca613f177f6ff7a3bbb6494cc79.tar.gz
brokengine-06d3e8182d018ca613f177f6ff7a3bbb6494cc79.tar.bz2
brokengine-06d3e8182d018ca613f177f6ff7a3bbb6494cc79.zip
Various additions
Various additions, updates, and bugfixes while making mahjong solitare.
Diffstat (limited to 'src/shared/lua_api/common.c')
-rw-r--r--src/shared/lua_api/common.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/shared/lua_api/common.c b/src/shared/lua_api/common.c
index 9a8baca..2eeee11 100644
--- a/src/shared/lua_api/common.c
+++ b/src/shared/lua_api/common.c
@@ -153,6 +153,43 @@ int popvector3d(lua_State* L,double* a,double* b,double* c){
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);