diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-10-19 13:34:05 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-10-19 13:34:05 +0200 |
commit | cc600de51f5946af5d4018b7681f2c11c68662e7 (patch) | |
tree | 73782543b31568c66bba5d1f87ea0ffcbdca2357 /src/Bindings/LuaState.cpp | |
parent | Use std::thread (diff) | |
parent | cLuaState: cMonster descendants don't push their specific type. (diff) | |
download | cuberite-cc600de51f5946af5d4018b7681f2c11c68662e7.tar cuberite-cc600de51f5946af5d4018b7681f2c11c68662e7.tar.gz cuberite-cc600de51f5946af5d4018b7681f2c11c68662e7.tar.bz2 cuberite-cc600de51f5946af5d4018b7681f2c11c68662e7.tar.lz cuberite-cc600de51f5946af5d4018b7681f2c11c68662e7.tar.xz cuberite-cc600de51f5946af5d4018b7681f2c11c68662e7.tar.zst cuberite-cc600de51f5946af5d4018b7681f2c11c68662e7.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/LuaState.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 85e3f9fc5..2c4d89b01 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -16,6 +16,8 @@ extern "C" #include "Bindings.h" #include "ManualBindings.h" #include "DeprecatedBindings.h" +#include "../Entities/Entity.h" +#include "../BlockEntities/BlockEntity.h" // fwd: SQLite/lsqlite3.c extern "C" @@ -520,7 +522,7 @@ void cLuaState::Push(cBlockEntity * a_BlockEntity) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_BlockEntity, "cBlockEntity"); + tolua_pushusertype(m_LuaState, a_BlockEntity, (a_BlockEntity == nullptr) ? "cBlockEntity" : a_BlockEntity->GetClass()); m_NumCurrentFunctionArgs += 1; } @@ -556,7 +558,16 @@ void cLuaState::Push(cEntity * a_Entity) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, a_Entity, "cEntity"); + if (a_Entity->IsMob()) + { + // Don't push specific mob types, as those are not exported in the API: + tolua_pushusertype(m_LuaState, a_Entity, "cMonster"); + } + else + { + // Push the specific class type: + tolua_pushusertype(m_LuaState, a_Entity, (a_Entity == nullptr) ? "cEntity" : a_Entity->GetClass()); + } m_NumCurrentFunctionArgs += 1; } |