]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/script/common/c_content.cpp
LocalPlayer:set_physics_override; minetest.register_on_recieve_physics_override
[dragonfireclient.git] / src / script / common / c_content.cpp
index 44b638ba7b963745da621d7f37198f1a91944284..78c46f0e086f5842bc4caa61fafc3ae83d644870 100644 (file)
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "object_properties.h"
 #include "collision.h"
 #include "cpp_api/s_node.h"
+#include "lua_api/l_clientobject.h"
 #include "lua_api/l_object.h"
 #include "lua_api/l_item.h"
 #include "common/c_internal.h"
@@ -1306,6 +1307,20 @@ void push_tool_capabilities(lua_State *L,
                lua_setfield(L, -2, "damage_groups");
 }
 
+/******************************************************************************/
+void push_inventory(lua_State *L, Inventory *inventory)
+{
+       std::vector<const InventoryList*> lists = inventory->getLists();
+       std::vector<const InventoryList*>::iterator iter = lists.begin();
+       lua_createtable(L, 0, lists.size());
+       for (; iter != lists.end(); iter++) {
+               const char* name = (*iter)->getName().c_str();
+               lua_pushstring(L, name);
+               push_inventory_list(L, inventory, name);
+               lua_rawset(L, -3);
+       }
+}
+
 /******************************************************************************/
 void push_inventory_list(lua_State *L, Inventory *inv, const char *name)
 {
@@ -1822,14 +1837,15 @@ void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm,
        } else if (pointed.type == POINTEDTHING_OBJECT) {
                lua_pushstring(L, "object");
                lua_setfield(L, -2, "type");
-
                if (csm) {
-                       lua_pushinteger(L, pointed.object_id);
-                       lua_setfield(L, -2, "id");
+#ifndef SERVER
+                       ClientObjectRef::create(L, pointed.object_id);
+#endif
                } else {
                        push_objectRef(L, pointed.object_id);
-                       lua_setfield(L, -2, "ref");
                }
+               
+               lua_setfield(L, -2, "ref");
        } else {
                lua_pushstring(L, "nothing");
                lua_setfield(L, -2, "type");
@@ -2080,3 +2096,26 @@ void push_collision_move_result(lua_State *L, const collisionMoveResult &res)
        lua_setfield(L, -2, "collisions");
        /**/
 }
+
+void push_physics_override(lua_State *L, float speed, float jump, float gravity, bool sneak, bool sneak_glitch, bool new_move)
+{
+       lua_createtable(L, 0, 6);
+       
+       lua_pushnumber(L, speed);
+       lua_setfield(L, -2, "speed");
+
+       lua_pushnumber(L, jump);
+       lua_setfield(L, -2, "jump");
+
+       lua_pushnumber(L, gravity);
+       lua_setfield(L, -2, "gravity");
+
+       lua_pushboolean(L, sneak);
+       lua_setfield(L, -2, "sneak");
+
+       lua_pushboolean(L, sneak_glitch);
+       lua_setfield(L, -2, "sneak_glitch");
+
+       lua_pushboolean(L, new_move);
+       lua_setfield(L, -2, "new_move");
+}