From 00e9c18ce61dc8181c11a89a2fb774b8ab315451 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Sun, 1 Apr 2018 00:33:57 -0700 Subject: [PATCH] Initial Commit --- .luacheckrc | 15 +++++++++++ depends.txt | 0 description.txt | 1 + init.lua | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ mod.conf | 1 + 5 files changed, 83 insertions(+) create mode 100644 .luacheckrc create mode 100644 depends.txt create mode 100644 description.txt create mode 100644 init.lua create mode 100644 mod.conf diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..15eed66 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,15 @@ +unused_args = false +allow_defined_top = true + +read_globals = { + "DIR_DELIM", + "minetest", "core", + "dump", + "vector", "nodeupdate", + "VoxelManip", "VoxelArea", + "PseudoRandom", "ItemStack", + "intllib", + "default", + table = { fields = { "copy", "getn" } } +} + diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..e69de29 diff --git a/description.txt b/description.txt new file mode 100644 index 0000000..f6468d1 --- /dev/null +++ b/description.txt @@ -0,0 +1 @@ +Allows you to have different day and night speeds. diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..c016cda --- /dev/null +++ b/init.lua @@ -0,0 +1,66 @@ + +--[[ + +Copyright 2018 - Auke Kok + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR +BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES +OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +]]-- + +local S = minetest.get_mod_storage() +assert(S) +local G = minetest.settings +assert(G) + +local function nightandday() + minetest.after(3.7, nightandday) + + local ds = S:get_int("day_time_speed") or 72 + local ns = S:get_int("night_time_speed") or 72 + + local t = minetest.get_timeofday() + + if t > 0.25 and t <= 0.75 then + if t ~= ds then + G:set("time_speed", ds) + end + else + if t ~= ns then + G:set("time_speed", ns) + end + end +end + +minetest.register_chatcommand("nightandday", { + params = "nightandday server", + description = "Change day and night speeds", + privs = {server = true}, + func = function(name, param) + local p = string.split(param, " ", false, 2, false) + if #p == 2 then + local ds = tonumber(p[1]) + local ns = tonumber(p[2]) + if ds < 1 or ns < 1 then + return false, "Usage: /nightandday dayspeed nightspeed" + end + S:set_int("day_time_speed", ds) + S:set_int("night_time_speed", ns) + return true, "Speeds set to: " .. ds .. ", " .. ns + else + return false, "Usage: /nightandday dayspeed nightspeed" + end + end +}) + +minetest.after(3.7, nightandday) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..f173e8e --- /dev/null +++ b/mod.conf @@ -0,0 +1 @@ +name = nightandday