mirror of
https://github.com/mt-mods/led_marquee.git
synced 2024-11-30 19:13:47 +01:00
fix glitch where first byte of msg gets skipped on scroll
(causes color code to be displayed raw)
This commit is contained in:
parent
cf94878a46
commit
3f98601875
5
init.lua
5
init.lua
@ -153,6 +153,7 @@ led_marquee.set_timer = function(pos, timeout)
|
|||||||
end
|
end
|
||||||
|
|
||||||
led_marquee.scroll_text = function(pos, elapsed, skip)
|
led_marquee.scroll_text = function(pos, elapsed, skip)
|
||||||
|
skip = skip or 1
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
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")
|
||||||
@ -161,8 +162,8 @@ led_marquee.scroll_text = function(pos, elapsed, skip)
|
|||||||
local colorchar = color_to_char[color+1]
|
local colorchar = color_to_char[color+1]
|
||||||
if not index or index < 1 or not string.byte(msg, index) then index = 1 end
|
if not index or index < 1 or not string.byte(msg, index) then index = 1 end
|
||||||
local len = string.len(msg)
|
local len = string.len(msg)
|
||||||
skip = skip or 1
|
|
||||||
index = index + skip
|
index = index + skip
|
||||||
|
if index > len then index = 1 end
|
||||||
|
|
||||||
-- search backward to find the most recent color code in the string
|
-- search backward to find the most recent color code in the string
|
||||||
local r = index
|
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
|
-- search forward to find the next printable symbol after the current index
|
||||||
local f = index
|
local f = index
|
||||||
while f < len do
|
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
|
f = f + 2
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user