don't reset index to 1 on timer-start

(that's handled elsewhere)

also, pre-increment the index so that it matches what's displayed
This commit is contained in:
Vanessa Dannenberg 2018-08-17 11:38:51 -04:00
parent 5826209f16
commit 010dab660b

@ -62,7 +62,6 @@ led_marquee.set_timer = function(pos, timeout)
timer:stop() timer:stop()
if timeout > 0 then if timeout > 0 then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("index", 1)
timer:start(timeout) timer:start(timeout)
end end
end end
@ -73,10 +72,11 @@ led_marquee.scroll_text = function(pos, elapsed)
local msg = meta:get_string("last_msg") local msg = meta:get_string("last_msg")
local channel = meta:get_string("channel") local channel = meta:get_string("channel")
if not index or index < 1 or index > string.len(msg) then index = 1 end if not index or index < 1 or index > string.len(msg) then index = 1 end
if string.byte(string.sub(msg,1,1)) < 32 then index = index + 1 end
index = index + 1
meta:set_int("index", index)
msg = string.sub(msg, index) msg = string.sub(msg, index)
led_marquee.display_msg(pos, channel, msg.." ") led_marquee.display_msg(pos, channel, msg.." ")
if string.byte(string.sub(msg,1,1)) < 32 then index = index + 1 end
meta:set_int("index", index + 1)
if not elapsed or elapsed < 0.5 then return false end if not elapsed or elapsed < 0.5 then return false end
return true return true
end end
@ -214,7 +214,6 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
meta:set_string("last_msg", msg) meta:set_string("last_msg", msg)
led_marquee.display_msg(pos, channel, msg) led_marquee.display_msg(pos, channel, msg)
meta:set_int("index", 1) meta:set_int("index", 1)
end end
else else
local asc = string.byte(msg) local asc = string.byte(msg)