summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-01-03 12:38:00 +0100
committerGitHub <noreply@github.com>2018-01-03 12:38:00 +0100
commit177273006e121acdcedbe74e3ee4988439cd10e3 (patch)
tree9b9d8f76dc86d852d25686b6dcc66359b0c2d817 /src/Bindings/LuaState.cpp
parentLilypads can be on top of (frosted) ice (#4122) (diff)
downloadcuberite-177273006e121acdcedbe74e3ee4988439cd10e3.tar
cuberite-177273006e121acdcedbe74e3ee4988439cd10e3.tar.gz
cuberite-177273006e121acdcedbe74e3ee4988439cd10e3.tar.bz2
cuberite-177273006e121acdcedbe74e3ee4988439cd10e3.tar.lz
cuberite-177273006e121acdcedbe74e3ee4988439cd10e3.tar.xz
cuberite-177273006e121acdcedbe74e3ee4988439cd10e3.tar.zst
cuberite-177273006e121acdcedbe74e3ee4988439cd10e3.zip
Diffstat (limited to 'src/Bindings/LuaState.cpp')
-rw-r--r--src/Bindings/LuaState.cpp82
1 files changed, 35 insertions, 47 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index ab3a38618..095322bdd 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -960,54 +960,42 @@ void cLuaState::Push(cEntity * a_Entity)
}
else
{
- switch (a_Entity->GetEntityType())
- {
- case cEntity::etMonster:
- {
- // Don't push specific mob types, as those are not exported in the API:
- tolua_pushusertype(m_LuaState, a_Entity, "cMonster");
- break;
- }
- case cEntity::etPlayer:
+ const char * ClassName = [&]
{
- tolua_pushusertype(m_LuaState, a_Entity, "cPlayer");
- break;
- }
- case cEntity::etPickup:
- {
- tolua_pushusertype(m_LuaState, a_Entity, "cPickup");
- break;
- }
- case cEntity::etTNT:
- {
- tolua_pushusertype(m_LuaState, a_Entity, "cTNTEntity");
- break;
- }
- case cEntity::etProjectile:
- {
- tolua_pushusertype(m_LuaState, a_Entity, a_Entity->GetClass());
- break;
- }
- case cEntity::etFloater:
- {
- tolua_pushusertype(m_LuaState, a_Entity, "cFloater");
- break;
- }
-
- case cEntity::etEntity:
- case cEntity::etEnderCrystal:
- case cEntity::etFallingBlock:
- case cEntity::etMinecart:
- case cEntity::etBoat:
- case cEntity::etExpOrb:
- case cEntity::etItemFrame:
- case cEntity::etPainting:
- case cEntity::etLeashKnot:
- {
- // Push the generic entity class type:
- tolua_pushusertype(m_LuaState, a_Entity, "cEntity");
- }
- } // switch (EntityType)
+ switch (a_Entity->GetEntityType())
+ {
+ case cEntity::etBoat: return "cBoat";
+ case cEntity::etExpOrb: return "cExpOrb";
+ case cEntity::etFallingBlock: return "cFallingBlock";
+ case cEntity::etFloater: return "cFloater";
+ case cEntity::etItemFrame: return "cItemFrame";
+ case cEntity::etLeashKnot: return "cLeashKnot";
+ case cEntity::etPainting: return "cPainting";
+ case cEntity::etPickup: return "cPickup";
+ case cEntity::etPlayer: return "cPlayer";
+ case cEntity::etTNT: return "cTNTEntity";
+
+ case cEntity::etMonster:
+ {
+ // Don't push specific mob types, as those are not exported in the API:
+ return "cMonster";
+ }
+ case cEntity::etProjectile:
+ {
+ // Push the specific projectile type:
+ return a_Entity->GetClass();
+ }
+
+ case cEntity::etEntity:
+ case cEntity::etEnderCrystal:
+ case cEntity::etMinecart:
+ {
+ // Push the generic entity class type:
+ return "cEntity";
+ }
+ } // switch (EntityType)
+ }();
+ tolua_pushusertype(m_LuaState, a_Entity, ClassName);
}
}