mirror of
https://github.com/mt-mods/led_marquee.git
synced 2024-11-24 08:13:52 +01:00
consolidate timer sanity checking into led_marquee.set_timer
This commit is contained in:
parent
0bc150e64a
commit
cf94878a46
6
init.lua
6
init.lua
@ -143,8 +143,11 @@ end
|
|||||||
led_marquee.set_timer = function(pos, timeout)
|
led_marquee.set_timer = function(pos, timeout)
|
||||||
local timer = minetest.get_node_timer(pos)
|
local timer = minetest.get_node_timer(pos)
|
||||||
timer:stop()
|
timer:stop()
|
||||||
|
if not timeout or timeout < 0.2 or timeout > 5 then return false end
|
||||||
|
|
||||||
if timeout > 0 then
|
if timeout > 0 then
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_int("timeout", timeout)
|
||||||
timer:start(timeout)
|
timer:start(timeout)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -318,15 +321,12 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
|
|||||||
meta:set_int("index", 1)
|
meta:set_int("index", 1)
|
||||||
elseif msg == "start_scroll" then
|
elseif msg == "start_scroll" then
|
||||||
local timeout = meta:get_int("timeout")
|
local timeout = meta:get_int("timeout")
|
||||||
if not timeout or timeout < 0.2 or timeout > 5 then timeout = 0 end
|
|
||||||
led_marquee.set_timer(pos, timeout)
|
led_marquee.set_timer(pos, timeout)
|
||||||
elseif msg == "stop_scroll" then
|
elseif msg == "stop_scroll" then
|
||||||
led_marquee.set_timer(pos, 0)
|
led_marquee.set_timer(pos, 0)
|
||||||
return
|
return
|
||||||
elseif string.sub(msg, 1, 12) == "scroll_speed" then
|
elseif string.sub(msg, 1, 12) == "scroll_speed" then
|
||||||
local timeout = tonumber(string.sub(msg, 13))
|
local timeout = tonumber(string.sub(msg, 13))
|
||||||
if not timeout or timeout < 0.2 or timeout > 5 then timeout = 0 end
|
|
||||||
meta:set_int("timeout", timeout)
|
|
||||||
led_marquee.set_timer(pos, timeout)
|
led_marquee.set_timer(pos, timeout)
|
||||||
elseif string.sub(msg, 1, 11) == "scroll_step" then
|
elseif string.sub(msg, 1, 11) == "scroll_step" then
|
||||||
local skip = tonumber(string.sub(msg, 12))
|
local skip = tonumber(string.sub(msg, 12))
|
||||||
|
Loading…
Reference in New Issue
Block a user