]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/script/cpp_api/s_entity.cpp
Expose getPointedThing to Lua
[dragonfireclient.git] / src / script / cpp_api / s_entity.cpp
index fcd8dd4a07033c8ba18a9a599c65d58c9bf59c32..4c1e296d4925e63fa2aba18af9a0ac99fc24737f 100644 (file)
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "object_properties.h"
 #include "common/c_converter.h"
 #include "common/c_content.h"
+#include "server.h"
 
 bool ScriptApiEntity::luaentity_Add(u16 id, const char *name)
 {
@@ -56,7 +57,7 @@ bool ScriptApiEntity::luaentity_Add(u16 id, const char *name)
 
        // Add object reference
        // This should be userdata with metatable ObjectRef
-       objectrefGet(L, id);
+       push_objectRef(L, id);
        luaL_checktype(L, -1, LUA_TUSERDATA);
        if (!luaL_checkudata(L, -1, "ObjectRef"))
                luaL_typerror(L, -1, "ObjectRef");
@@ -187,11 +188,11 @@ void ScriptApiEntity::luaentity_GetProperties(u16 id,
        getstringfield(L, -1, "mesh", prop->mesh);
 
        // Deprecated: read object properties directly
-       read_object_properties(L, -1, prop);
+       read_object_properties(L, -1, prop, getServer()->idef());
 
        // Read initial_properties
        lua_getfield(L, -1, "initial_properties");
-       read_object_properties(L, -1, prop);
+       read_object_properties(L, -1, prop, getServer()->idef());
        lua_pop(L, 1);
 }
 
@@ -254,7 +255,7 @@ bool ScriptApiEntity::luaentity_Punch(u16 id,
        lua_pushnumber(L, damage);
 
        setOriginFromTable(object);
-       PCALL_RES(lua_pcall(L, 6, 0, error_handler));
+       PCALL_RES(lua_pcall(L, 6, 1, error_handler));
 
        bool retval = lua_toboolean(L, -1);
        lua_pop(L, 2); // Pop object and error handler