summaryrefslogtreecommitdiffstats
path: root/source/Plugin_NewLua.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-13 20:22:08 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-13 20:22:08 +0100
commit8b1a8bee3437f5d8f865e77e27ae15ad4c690f10 (patch)
tree4dfd2af1af81457636feae7f25dedde794ed6be9 /source/Plugin_NewLua.cpp
parentAdded a forgotten part of the cBlockArea::FillRelCuboid() function. (diff)
downloadcuberite-8b1a8bee3437f5d8f865e77e27ae15ad4c690f10.tar
cuberite-8b1a8bee3437f5d8f865e77e27ae15ad4c690f10.tar.gz
cuberite-8b1a8bee3437f5d8f865e77e27ae15ad4c690f10.tar.bz2
cuberite-8b1a8bee3437f5d8f865e77e27ae15ad4c690f10.tar.lz
cuberite-8b1a8bee3437f5d8f865e77e27ae15ad4c690f10.tar.xz
cuberite-8b1a8bee3437f5d8f865e77e27ae15ad4c690f10.tar.zst
cuberite-8b1a8bee3437f5d8f865e77e27ae15ad4c690f10.zip
Diffstat (limited to 'source/Plugin_NewLua.cpp')
-rw-r--r--source/Plugin_NewLua.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/source/Plugin_NewLua.cpp b/source/Plugin_NewLua.cpp
index d83a88f96..249c9fafd 100644
--- a/source/Plugin_NewLua.cpp
+++ b/source/Plugin_NewLua.cpp
@@ -1210,7 +1210,7 @@ bool cPlugin_NewLua::OnUpdatingSign(
-bool cPlugin_NewLua::OnWeatherChanged(cWorld * a_World)
+bool cPlugin_NewLua::OnWeatherChanged(cWorld & a_World)
{
cCSLock Lock(m_CriticalSection);
const char * FnName = GetHookFnName(cPluginManager::HOOK_WEATHER_CHANGED);
@@ -1220,7 +1220,7 @@ bool cPlugin_NewLua::OnWeatherChanged(cWorld * a_World)
return false;
}
- tolua_pushusertype(m_LuaState, (void *)a_World, "cWorld");
+ tolua_pushusertype(m_LuaState, &a_World, "cWorld");
if (!CallFunction(1, 1, FnName))
{
@@ -1236,6 +1236,37 @@ bool cPlugin_NewLua::OnWeatherChanged(cWorld * a_World)
+bool cPlugin_NewLua::OnWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
+{
+ cCSLock Lock(m_CriticalSection);
+ const char * FnName = GetHookFnName(cPluginManager::HOOK_WEATHER_CHANGED);
+ ASSERT(FnName != NULL);
+ if (!PushFunction(FnName))
+ {
+ return false;
+ }
+
+ tolua_pushusertype(m_LuaState, &a_World, "cWorld");
+ tolua_pushnumber (m_LuaState, a_NewWeather);
+
+ if (!CallFunction(2, 2, FnName))
+ {
+ return false;
+ }
+
+ bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0);
+ if (lua_isnumber(m_LuaState, -2))
+ {
+ a_NewWeather = (eWeather)lua_tointeger(m_LuaState, -2);
+ }
+ lua_pop(m_LuaState, 1);
+ return bRetVal;
+}
+
+
+
+
+
bool cPlugin_NewLua::HandleCommand(const AStringVector & a_Split, cPlayer * a_Player)
{
ASSERT(!a_Split.empty());
@@ -1395,6 +1426,7 @@ const char * cPlugin_NewLua::GetHookFnName(cPluginManager::PluginHook a_Hook)
case cPluginManager::HOOK_UPDATED_SIGN: return "OnUpdatedSign";
case cPluginManager::HOOK_UPDATING_SIGN: return "OnUpdatingSign";
case cPluginManager::HOOK_WEATHER_CHANGED: return "OnWeatherChanged";
+ case cPluginManager::HOOK_WEATHER_CHANGING: return "OnWeatherChanging";
default: return NULL;
} // switch (a_Hook)
}