1
0
mirror of https://github.com/mt-mods/led_marquee.git synced 2025-09-08 09:25:38 +02:00

10 Commits

Author SHA1 Message Date
Vanessa Dannenberg
589ab5f19a don't reset scroll position if re-printing the same message 2018-08-22 18:40:58 -04:00
Vanessa Dannenberg
bbb2b57328 fix shifted block shades (char 143, 144) 2018-08-21 21:14:27 -04:00
Vanessa Dannenberg
1b2e898615 remove debug prints 2018-08-21 05:48:41 -04:00
Vanessa Dannenberg
2d74ccf8e6 fix the fix ;) 2018-08-21 04:59:58 -04:00
Vanessa Dannenberg
3f98601875 fix glitch where first byte of msg gets skipped on scroll
(causes color code to be displayed raw)
2018-08-21 04:47:00 -04:00
Vanessa Dannenberg
cf94878a46 consolidate timer sanity checking into led_marquee.set_timer 2018-08-21 04:22:22 -04:00
Vanessa Dannenberg
0bc150e64a reduce allowed minimum timeout to 0.2s 2018-08-21 04:15:37 -04:00
Vanessa Dannenberg
f9f68d13ab better centering for k 2018-08-21 01:35:45 -04:00
Vanessa Dannenberg
ddfed65b2a better centering for y ÿ ý 2018-08-21 01:30:48 -04:00
Vanessa Dannenberg
85fd214907 better shape for "Ý" 2018-08-21 01:26:34 -04:00
9 changed files with 14 additions and 10 deletions

View File

@@ -49,7 +49,7 @@ The panels also respond to these control messages:
As it advances through the message, the scroll code will search through the message for a printable character, on each scroll step, basically stripping-out color code, and using just the last one before the new start position. This is done in order to keep a constant visible speed (the text will still be colored properly though). As it advances through the message, the scroll code will search through the message for a printable character, on each scroll step, basically stripping-out color code, and using just the last one before the new start position. This is done in order to keep a constant visible speed (the text will still be colored properly though).
* "stop_scroll" does just what it says - it stops the auto-scroll timer. * "stop_scroll" does just what it says - it stops the auto-scroll timer.
* "scroll_speed" followed by a decimal number (in the string, not a byte value) sets the time between scroll steps. Minimum 0.5s, maximum 5s. * "scroll_speed" followed by a decimal number (in the string, not a byte value) sets the time between scroll steps. Minimum 0.2s, maximum 5s.
* "scroll_step" will immediately advance the last-displayed message by one character. Omit the above automatic scrolling keywords, and use ONLY this keyword instead if you want to let your LuaController control the scrolling speed. Optionally, you can follow this with a number and the scroll code will skip forward that many bytes into the message, starting from the current position, before starting the above-mentioned color-vs-character search. Essentially, this value will roughly translate to the number of printable characters to skip. * "scroll_step" will immediately advance the last-displayed message by one character. Omit the above automatic scrolling keywords, and use ONLY this keyword instead if you want to let your LuaController control the scrolling speed. Optionally, you can follow this with a number and the scroll code will skip forward that many bytes into the message, starting from the current position, before starting the above-mentioned color-vs-character search. Essentially, this value will roughly translate to the number of printable characters to skip.
* "get" will read the one character (as a numerical character value) currently displayed by the master panel (by reading its node name) * "get" will read the one character (as a numerical character value) currently displayed by the master panel (by reading its node name)
* "getstr" will read the last-stored message for the entire lineup/wall (from the master panel's meta). Note that even if the message has been or is being scrolled, you'll get the original stored message. * "getstr" will read the last-stored message for the entire lineup/wall (from the master panel's meta). Note that even if the message has been or is being scrolled, you'll get the original stored message.

View File

@@ -143,23 +143,27 @@ 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
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")
local index = meta:get_int("index") local index = meta:get_int("index")
local color = meta:get_int("last_color") local color = meta:get_int("last_color")
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 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
@@ -174,16 +178,16 @@ 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
end end
end end
led_marquee.display_msg(pos, channel, "/"..colorchar..string.sub(msg, f)..string.rep(" ", skip + 1)) led_marquee.display_msg(pos, channel, "/"..colorchar..string.sub(msg, f)..string.rep(" ", skip + 1))
meta:set_int("index", f) meta:set_int("index", f)
if not elapsed or elapsed < 0.5 then return false end if not elapsed or elapsed < 0.2 then return false end
return true return true
end end
@@ -318,15 +322,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.5 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.5 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))
@@ -340,9 +341,12 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
else else
msg = string.gsub(msg, "//", string.char(30)) msg = string.gsub(msg, "//", string.char(30))
led_marquee.set_timer(pos, 0) led_marquee.set_timer(pos, 0)
local last_msg = meta:get_string("last_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) if last_msg ~= msg then
meta:set_int("index", 1)
end
end end
else else
local asc = string.byte(msg) local asc = string.byte(msg)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 B

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 B

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 362 B