summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginLua.cpp
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-07-10 08:28:27 +0200
committerarchshift <admin@archshift.com>2014-07-10 08:28:27 +0200
commite824cd09b369c47a7f316fccc7577cd923164466 (patch)
treed8efa178a29955525458a38b1351ea0b609a2a09 /src/Bindings/PluginLua.cpp
parentEntityEffects.x -> EntityEffect.x, Object-Oriented effects (diff)
parentMerge pull request #1157 from Howaner/Window (diff)
downloadcuberite-e824cd09b369c47a7f316fccc7577cd923164466.tar
cuberite-e824cd09b369c47a7f316fccc7577cd923164466.tar.gz
cuberite-e824cd09b369c47a7f316fccc7577cd923164466.tar.bz2
cuberite-e824cd09b369c47a7f316fccc7577cd923164466.tar.lz
cuberite-e824cd09b369c47a7f316fccc7577cd923164466.tar.xz
cuberite-e824cd09b369c47a7f316fccc7577cd923164466.tar.zst
cuberite-e824cd09b369c47a7f316fccc7577cd923164466.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/PluginLua.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 09ffa6064..e10cca708 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -735,6 +735,26 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player)
+bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
+{
+ cCSLock Lock(m_CriticalSection);
+ bool res = false;
+ cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE];
+ for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
+ {
+ m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res);
+ if (res)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward)
{
cCSLock Lock(m_CriticalSection);
@@ -1347,18 +1367,15 @@ bool cPluginLua::OnWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
- int NewWeather = a_NewWeather;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WEATHER_CHANGING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, NewWeather, cLuaState::Return, res, NewWeather);
+ m_LuaState.Call((int)(**itr), &a_World, a_NewWeather, cLuaState::Return, res, a_NewWeather);
if (res)
{
- a_NewWeather = (eWeather)NewWeather;
return true;
}
}
- a_NewWeather = (eWeather)NewWeather;
return false;
}
@@ -1592,6 +1609,7 @@ bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx)
LOGWARNING("Plugin %s tried to add a hook %d with bad handler function.", GetName().c_str(), a_HookType);
m_LuaState.LogStackTrace();
delete Ref;
+ Ref = NULL;
return false;
}
@@ -1734,7 +1752,7 @@ bool cPluginLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer
ASSERT(a_FnRef != LUA_REFNIL);
cCSLock Lock(m_CriticalSection);
- bool res;
+ bool res = false;
m_LuaState.Call(a_FnRef, &a_Window, &a_Player, a_CanRefuse, cLuaState::Return, res);
return res;
}