summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/ManualBindings.cpp31
-rw-r--r--src/Bindings/ManualBindings_World.cpp104
-rw-r--r--src/Bindings/PluginManager.cpp2
3 files changed, 131 insertions, 6 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 20364100f..cd5e69b22 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -2338,6 +2338,36 @@ static int tolua_cClientHandle_SendPluginMessage(lua_State * L)
+static int tolua_cClientHandle_SendTimeUpdate(lua_State * L)
+{
+ cLuaState S(L);
+ if (
+ !S.CheckParamSelf("cClientHandle") ||
+ !S.CheckParamNumber(2, 3) ||
+ !S.CheckParamBool(4) ||
+ !S.CheckParamEnd(5)
+ )
+ {
+ return 0;
+ }
+
+ cClientHandle * Client;
+ cTickTimeLong::rep WorldAge, WorldDate;
+ bool DoDayLightCycle;
+ S.GetStackValues(1, Client, WorldAge, WorldDate, DoDayLightCycle);
+ if (Client == nullptr)
+ {
+ return S.ApiParamError("Invalid 'self'");
+ }
+
+ Client->SendTimeUpdate(cTickTimeLong(WorldAge), cTickTimeLong(WorldDate), DoDayLightCycle);
+ return 0;
+}
+
+
+
+
+
static int tolua_cClientHandle_GetForgeMods(lua_State * L)
{
cLuaState S(L);
@@ -4361,6 +4391,7 @@ void cManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "GetForgeMods", tolua_cClientHandle_GetForgeMods);
tolua_function(tolua_S, "SendPluginMessage", tolua_cClientHandle_SendPluginMessage);
+ tolua_function(tolua_S, "SendTimeUpdate", tolua_cClientHandle_SendTimeUpdate);
tolua_function(tolua_S, "GetUUID", tolua_cClientHandle_GetUUID);
tolua_function(tolua_S, "GenerateOfflineUUID", tolua_cClientHandle_GenerateOfflineUUID);
tolua_function(tolua_S, "IsUUIDOnline", tolua_cClientHandle_IsUUIDOnline);
diff --git a/src/Bindings/ManualBindings_World.cpp b/src/Bindings/ManualBindings_World.cpp
index db797483d..6de6f10bd 100644
--- a/src/Bindings/ManualBindings_World.cpp
+++ b/src/Bindings/ManualBindings_World.cpp
@@ -1266,6 +1266,70 @@ static int tolua_cWorld_GetSignLines(lua_State * tolua_S)
+static int tolua_cWorld_GetTimeOfDay(lua_State * tolua_S)
+{
+ // Check params:
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamSelf("cWorld") ||
+ !L.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Get params:
+ cWorld * Self = nullptr;
+ L.GetStackValues(1, Self);
+ if (Self == nullptr)
+ {
+ return L.ApiParamError("Invalid 'self'");
+ }
+
+ // Call the function:
+ const auto Time = Self->GetTimeOfDay();
+
+ // Push the returned value:
+ L.Push(Time.count());
+ return 1;
+}
+
+
+
+
+
+static int tolua_cWorld_GetWorldAge(lua_State * tolua_S)
+{
+ // Check params:
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamSelf("cWorld") ||
+ !L.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Get params:
+ cWorld * Self = nullptr;
+ L.GetStackValues(1, Self);
+ if (Self == nullptr)
+ {
+ return L.ApiParamError("Invalid 'self'");
+ }
+
+ // Call the function:
+ const auto Time = Self->GetWorldAge();
+
+ // Push the returned value:
+ L.Push(static_cast<lua_Number>(Time.count()));
+ return 1;
+}
+
+
+
+
+
static int tolua_cWorld_PrepareChunk(lua_State * tolua_S)
{
/* Function signature:
@@ -1459,6 +1523,37 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
+static int tolua_cWorld_SetTimeOfDay(lua_State * tolua_S)
+{
+ // Check params:
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamSelf("cWorld") ||
+ !L.CheckParamNumber(2) ||
+ !L.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get params:
+ cWorld * Self = nullptr;
+ cTickTime::rep Time;
+ L.GetStackValues(1, Self, Time);
+ if (Self == nullptr)
+ {
+ return L.ApiParamError("Invalid 'self'");
+ }
+
+ // Call the function:
+ Self->SetTimeOfDay(cTickTime(Time));
+ return 0;
+}
+
+
+
+
+
static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
{
// Function signature:
@@ -1490,7 +1585,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Could not store the callback parameter");
}
- World->ScheduleTask(NumTicks, [Task](cWorld & a_World)
+ World->ScheduleTask(cTickTime(NumTicks), [Task](cWorld & a_World)
{
Task->Call(&a_World);
}
@@ -1624,17 +1719,16 @@ void cManualBindings::BindWorld(lua_State * tolua_S)
tolua_function(tolua_S, "GetBlockSkyLight", tolua_cWorld_GetBlockSkyLight);
tolua_function(tolua_S, "GetBlockTypeMeta", tolua_cWorld_GetBlockTypeMeta);
tolua_function(tolua_S, "GetSignLines", tolua_cWorld_GetSignLines);
+ tolua_function(tolua_S, "GetTimeOfDay", tolua_cWorld_GetTimeOfDay);
+ tolua_function(tolua_S, "GetWorldAge", tolua_cWorld_GetWorldAge);
tolua_function(tolua_S, "PrepareChunk", tolua_cWorld_PrepareChunk);
tolua_function(tolua_S, "QueueTask", tolua_cWorld_QueueTask);
tolua_function(tolua_S, "ScheduleTask", tolua_cWorld_ScheduleTask);
tolua_function(tolua_S, "SetBlock", tolua_cWorld_SetBlock);
tolua_function(tolua_S, "SetSignLines", tolua_cWorld_SetSignLines);
+ tolua_function(tolua_S, "SetTimeOfDay", tolua_cWorld_SetTimeOfDay);
tolua_function(tolua_S, "SpawnSplitExperienceOrbs", tolua_cWorld_SpawnSplitExperienceOrbs);
tolua_function(tolua_S, "TryGetHeight", tolua_cWorld_TryGetHeight);
tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
}
-
-
-
-
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 59761ead9..d790562dc 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -541,7 +541,7 @@ bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVec
if (world != nullptr)
{
worldName = world->GetName();
- worldAge = world->GetWorldAge();
+ worldAge = world->GetWorldAge().count();
}
else
{