forked from minetest-mods/MoreMesecons
Adjustable Blinky Plant: fix very fast blinking before having set an interval + add a minimum interval setting
This commit is contained in:
parent
17ddb23406
commit
c53ac5b660
@ -1,2 +1,3 @@
|
|||||||
mesecons
|
mesecons
|
||||||
|
moremesecons_utils
|
||||||
craft_guide?
|
craft_guide?
|
||||||
|
@ -4,7 +4,11 @@ local toggle_timer = function (pos, restart)
|
|||||||
and not restart then
|
and not restart then
|
||||||
timer:stop()
|
timer:stop()
|
||||||
else
|
else
|
||||||
timer:start(tonumber(minetest.get_meta(pos):get_string("interval")) or 0)
|
local interval = tonumber(minetest.get_meta(pos):get_string("interval")) or 1
|
||||||
|
if interval < moremesecons.setting("adjustable_blinky_plant", "min_interval", 0.5) then
|
||||||
|
interval = moremesecons.setting("adjustable_blinky_plant", "min_interval", 0.5)
|
||||||
|
end
|
||||||
|
timer:start(interval)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -30,7 +34,9 @@ mesecon.register_node("moremesecons_adjustable_blinkyplant:adjustable_blinky_pla
|
|||||||
},
|
},
|
||||||
on_timer = on_timer,
|
on_timer = on_timer,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
minetest.get_meta(pos):set_string("formspec", "field[interval;interval;${interval}]")
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("interval", "1")
|
||||||
|
meta:set_string("formspec", "field[interval;interval;${interval}]")
|
||||||
toggle_timer(pos, true)
|
toggle_timer(pos, true)
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, _, fields, player)
|
on_receive_fields = function(pos, _, fields, player)
|
||||||
|
@ -13,7 +13,10 @@ function moremesecons.setting(modname, settingname, default, min)
|
|||||||
return minetest.setting_get(setting) or default
|
return minetest.setting_get(setting) or default
|
||||||
elseif type(default) == "number" then
|
elseif type(default) == "number" then
|
||||||
local ret = tonumber(minetest.setting_get(setting)) or default
|
local ret = tonumber(minetest.setting_get(setting)) or default
|
||||||
if ret ~= ret then -- NaN
|
if not ret then
|
||||||
|
minetest.log("warning", "[moremesecons_"..modname.."]: setting '"..setting.."' must be a number. Set to default value ("..tostring(default)..").")
|
||||||
|
ret = default
|
||||||
|
elseif ret ~= ret then -- NaN
|
||||||
minetest.log("warning", "[moremesecons_"..modname.."]: setting '"..setting.."' is NaN. Set to default value ("..tostring(default)..").")
|
minetest.log("warning", "[moremesecons_"..modname.."]: setting '"..setting.."' is NaN. Set to default value ("..tostring(default)..").")
|
||||||
ret = default
|
ret = default
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
[Adjustable Blinky Plant]
|
||||||
|
|
||||||
|
# Minimal interval authorized. Any lower will be set to it.
|
||||||
|
moremesecons_adjustable_blinky_plant.min_interval (Minimum Interval) float 0.5
|
||||||
|
|
||||||
[Craftable Commandblock]
|
[Craftable Commandblock]
|
||||||
|
|
||||||
# Space-separated list of authorized commands
|
# Space-separated list of authorized commands
|
||||||
|
Loading…
Reference in New Issue
Block a user