35 lines
1.0 KiB
Lua
35 lines
1.0 KiB
Lua
local function clamp(val, min_val, max_val)
|
|
return math.min(math.max(val, min_val), max_val)
|
|
end
|
|
|
|
core.register_chatcommand(
|
|
"wolfvision",
|
|
{
|
|
privs = { interact = true },
|
|
func = function(player_name, params)
|
|
local p = core.get_player_by_name(player_name)
|
|
if not p then
|
|
return
|
|
end
|
|
|
|
local words = string.split(params, " ")
|
|
local saturation, light = 1.0, nil
|
|
if words[1] then
|
|
saturation = tonumber(words[1]) or 1.0
|
|
saturation = clamp(saturation, -2.0, 2.0)
|
|
end
|
|
if words[2] then
|
|
light = tonumber(words[2])
|
|
if light then
|
|
light = clamp(light, 0.0, 1.0)
|
|
end
|
|
end
|
|
|
|
p:set_lighting({saturation = saturation})
|
|
p:override_day_night_ratio(light)
|
|
|
|
return true, string.format("set: saturation=%s, light=%s %s", dump(saturation), dump(light), ".")
|
|
end,
|
|
}
|
|
)
|