aboutsummaryrefslogtreecommitdiff
path: root/ch_core/dennoc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'ch_core/dennoc.lua')
-rw-r--r--ch_core/dennoc.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/ch_core/dennoc.lua b/ch_core/dennoc.lua
new file mode 100644
index 0000000..f7a307a
--- /dev/null
+++ b/ch_core/dennoc.lua
@@ -0,0 +1,43 @@
+ch_core.open_submod("dennoc", {privs = true, chat = true})
+
+--[[
+ /dennoc
+ /dennoc den
+ /dennoc noc
+ /dennoc XX:XX
+]]
+
+local def = {
+ privs = {},
+ params = "[koeficient]",
+ description = "Nastaví osobní osvětlení světa.",
+ func = function(player_name, param)
+ local player = minetest.get_player_by_name(player_name)
+ if not player then
+ return false
+ end
+
+ local c
+ if param == "" then
+ player:override_day_night_ratio(nil)
+ ch_core.systemovy_kanal(player_name, "/dennoc: osobní osvětlení světa zrušeno")
+ return true
+ elseif param == "den" then
+ c = 1
+ elseif param == "noc" then
+ c = 0
+ else
+ local s = param:gsub(",", ".")
+ c = tonumber(s)
+ end
+ if c ~= nil and 0.0 <= c and c <= 1.0 then
+ player:override_day_night_ratio(c)
+ ch_core.systemovy_kanal(player_name, "/dennoc: osobní osvětlení světa nastaveno na koeficient "..c)
+ return true
+ end
+ return false, "Neplatný formát parametru!"
+ end
+}
+minetest.register_chatcommand("dennoc", def)
+
+ch_core.close_submod("dennoc")