aboutsummaryrefslogtreecommitdiff
path: root/src/shared/lua_api/common.c
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-10-28 18:12:50 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2017-10-28 18:12:50 -0400
commit61c0c9f53d3a57ee7fd5db5faa74c4b51e2da396 (patch)
tree7f828d9557aa28ffcb4c7a1b9b3e3326f3ad0170 /src/shared/lua_api/common.c
parent33e6b9627e6a46d388d46f2c5b4d15ba7e9f9904 (diff)
downloadbrokengine-61c0c9f53d3a57ee7fd5db5faa74c4b51e2da396.tar.gz
brokengine-61c0c9f53d3a57ee7fd5db5faa74c4b51e2da396.tar.bz2
brokengine-61c0c9f53d3a57ee7fd5db5faa74c4b51e2da396.zip
Lots of updates
* Networking is finally working * Started moveing physics into the shared domain * Streams now have a readString() and writeString() method * streams are passed to the lua context for networking * Refactored cameras and physboxes to use metatables * Finally wrote the pushvector3* and popvector3* methods * Fixed a few crashes in ;main * Deleted a lot of code
Diffstat (limited to 'src/shared/lua_api/common.c')
-rw-r--r--src/shared/lua_api/common.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/shared/lua_api/common.c b/src/shared/lua_api/common.c
index 1e0c971..140ece1 100644
--- a/src/shared/lua_api/common.c
+++ b/src/shared/lua_api/common.c
@@ -36,3 +36,81 @@ void loadLLibs(lua_State* L){
lua_call(L,1,0);
*/
}
+
+
+int pushvector3i(lua_State* L,long a,long b,long c){
+ 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);
+
+ lua_pushinteger(L,3);
+ lua_pushinteger(L,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 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;
+}