From 010dab660b8b65e28b73e88b0a2dc8db68fc9ecf Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Fri, 17 Aug 2018 11:38:51 -0400 Subject: [PATCH] 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 --- init.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 7924f38..4217091 100644 --- a/init.lua +++ b/init.lua @@ -62,7 +62,6 @@ led_marquee.set_timer = function(pos, timeout) timer:stop() if timeout > 0 then local meta = minetest.get_meta(pos) - meta:set_int("index", 1) timer:start(timeout) end end @@ -73,10 +72,11 @@ led_marquee.scroll_text = function(pos, elapsed) local msg = meta:get_string("last_msg") local channel = meta:get_string("channel") 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) 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 return true end @@ -214,7 +214,6 @@ local on_digiline_receive_string = function(pos, node, channel, msg) meta:set_string("last_msg", msg) led_marquee.display_msg(pos, channel, msg) meta:set_int("index", 1) - end else local asc = string.byte(msg)