From 3f9860187566a26607f6ca791dcc327200c09206 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Tue, 21 Aug 2018 04:27:58 -0400 Subject: [PATCH] fix glitch where first byte of msg gets skipped on scroll (causes color code to be displayed raw) --- init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 13d50cf..98ed7a9 100644 --- a/init.lua +++ b/init.lua @@ -153,6 +153,7 @@ led_marquee.set_timer = function(pos, timeout) end led_marquee.scroll_text = function(pos, elapsed, skip) + skip = skip or 1 local meta = minetest.get_meta(pos) local msg = meta:get_string("last_msg") local channel = meta:get_string("channel") @@ -161,8 +162,8 @@ led_marquee.scroll_text = function(pos, elapsed, skip) local colorchar = color_to_char[color+1] if not index or index < 1 or not string.byte(msg, index) then index = 1 end local len = string.len(msg) - skip = skip or 1 index = index + skip + if index > len then index = 1 end -- search backward to find the most recent color code in the string local r = index @@ -177,7 +178,7 @@ led_marquee.scroll_text = function(pos, elapsed, skip) -- search forward to find the next printable symbol after the current index local f = index while f < len do - if string.match(string.sub(msg, f, f+1), "/[0-9A-Ra-r]") then + if string.match(string.sub(msg, f-1, f), "/[0-9A-Ra-r]") then f = f + 2 else break