summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginLua.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-03-29 22:32:50 +0100
committerMattes D <github@xoft.cz>2014-03-29 22:32:50 +0100
commit37812813d3bf8011089bc6e117b226a14a844540 (patch)
treeaf60ec69801c9bd9a80d7b5328814c490cb6fc47 /src/Bindings/PluginLua.cpp
parentRenamed lua dll for tolua++.exe. (diff)
parentFixed the OnProjectileHitBlock hook not stopping projectiles. (diff)
downloadcuberite-37812813d3bf8011089bc6e117b226a14a844540.tar
cuberite-37812813d3bf8011089bc6e117b226a14a844540.tar.gz
cuberite-37812813d3bf8011089bc6e117b226a14a844540.tar.bz2
cuberite-37812813d3bf8011089bc6e117b226a14a844540.tar.lz
cuberite-37812813d3bf8011089bc6e117b226a14a844540.tar.xz
cuberite-37812813d3bf8011089bc6e117b226a14a844540.tar.zst
cuberite-37812813d3bf8011089bc6e117b226a14a844540.zip
Diffstat (limited to 'src/Bindings/PluginLua.cpp')
-rw-r--r--src/Bindings/PluginLua.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 4f0e13f12..7e69e0f4b 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -1108,6 +1108,46 @@ bool cPluginLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a
+bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile)
+{
+ cCSLock Lock(m_CriticalSection);
+ bool res = false;
+ cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK];
+ for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
+ {
+ m_LuaState.Call((int)(**itr), &a_Projectile, cLuaState::Return, res);
+ if (res)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
+bool cPluginLua::OnProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity & a_HitEntity)
+{
+ cCSLock Lock(m_CriticalSection);
+ bool res = false;
+ cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_ENTITY];
+ for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
+ {
+ m_LuaState.Call((int)(**itr), &a_Projectile, &a_HitEntity, cLuaState::Return, res);
+ if (res)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginLua::OnSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
{
cCSLock Lock(m_CriticalSection);