From 3470687be0af7254aca478ead1e9c72757edf070 Mon Sep 17 00:00:00 2001 From: orwell Date: Tue, 27 May 2025 21:17:10 +0200 Subject: Add CH dependencies temporarily. Before merge to master should remove them again and split out util functions (e.g. formspec lib) --- ch_core/dennoc.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ch_core/dennoc.lua (limited to 'ch_core/dennoc.lua') 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") -- cgit v1.2.3