1
0
mirror of https://github.com/mt-mods/led_marquee.git synced 2025-06-28 22:36:41 +02:00

9 Commits

Author SHA1 Message Date
63de1f5ab5 Don't allow engine to add the implicit "Proceed" button
(this change makes it possible to theme the formspec)
2021-02-25 02:08:22 -05:00
642aec419a Merge branch 'master' into 'master'
fix crash when "scroll_speed" is not a number

See merge request VanessaE/led_marquee!5
2020-09-09 10:29:17 +00:00
caf6e24d04 fix crash when "scroll_speed" is not a number 2020-09-09 19:22:14 +10:00
31a938693a add minimum minetest version key for contentdb 2020-06-03 13:00:22 -04:00
45c89704f0 Add lag mitigation
All messages sent to the displays are firstr enqueued, then "played
back" on globalstep, similar to biome_lib's deferred-generation method.

By default, no more than 10 messages will be added to the queue.  If the
queue should exceed that, old messages will be deleted to make room for
new messages.

Messages will be pulled from the queue, one item per server tick, in the
order received, and relayed to their displays, if dtime <= 0.2s.  If
dtime is greater, messages will be withheld until it decreases.

Autoscroll now limits the speed to 0.5s per step.
2019-08-21 19:34:07 -04:00
8d3a0e92de Merge branch 'bad_unicode' into 'master'
add check to prevent bad unicode from crashing the server

See merge request VanessaE/led_marquee!4
2019-07-06 02:17:06 +00:00
db78e3dcdb add check to prevent bad unicode from crashing the server 2019-07-06 02:17:06 +00:00
da1deecb4c use masking:
glyph images are now used as masks over the "leds_on" image
instead of the glyphs themselves looking like they're made of LEDs.

Makes font files much simpler, easier to draw, makes LEDs easier
to re-texture.

White for "on" LEDs, black for "off"

Also optimized all images (optipng, pngcrush)
2019-05-25 03:52:00 -04:00
df30ce9477 Use hardware overlay instead of an extra face
to display the LEDs, gets rid of Z fighting due
to Irrlicht rounding errors
2019-05-25 03:00:14 -04:00
234 changed files with 61 additions and 34 deletions

View File

@ -2,6 +2,13 @@
-- by Vanessa Dannenberg
led_marquee = {}
led_marquee.scheduled_messages = {}
led_marquee.message_minimum_time = tonumber(minetest.settings:get("led_marquee_message_minimum_time")) or 0.5
led_marquee.message_schedule_dtime = tonumber(minetest.settings:get("led_marquee_message_schedule_dtime")) or 0.2
led_marquee.message_schedule_size = tonumber(minetest.settings:get("led_marquee_message_schedule_size")) or 10
led_marquee.relay_timer = 0
local S
if minetest.get_modpath("intllib") then
@ -96,7 +103,12 @@ local char_to_color = {
-- the following functions based on the so-named ones in Jeija's digilines mod
local reset_meta = function(pos)
minetest.get_meta(pos):set_string("formspec", "field[channel;Channel;${channel}]")
minetest.get_meta(pos):set_string("formspec",
"formspec_version[4]"..
"size[8,4]"..
"button_exit[3,2.5;2,0.5;proceed;Proceed]"..
"field[1.75,1.5;4.5,0.5;channel;Channel;${channel}]"
)
end
local on_digiline_receive_std = function(pos, node, channel, msg)
@ -128,7 +140,12 @@ local make_iso = function(s)
local s2 = ""
while i <= string.len(s) do
if string.byte(s,i) > 159 then
s2 = s2..string.char(get_iso(string.sub(s, i, i+1)))
local ciso = get_iso(string.sub(s, i, i+1))
if ciso >= 0 and ciso < 256 then
s2 = s2..string.char(ciso)
else
s2 = s2..string.char(127)
end
i = i + 2
else
s2 = s2..string.sub(s, i, i)
@ -143,7 +160,7 @@ end
led_marquee.set_timer = function(pos, timeout)
local timer = minetest.get_node_timer(pos)
timer:stop()
if not timeout or timeout < 0.2 or timeout > 5 then return false end
if not timeout or timeout < led_marquee.message_minimum_time or timeout > 5 then return false end
if timeout > 0 then
local meta = minetest.get_meta(pos)
@ -184,7 +201,7 @@ led_marquee.scroll_text = function(pos, elapsed, skip)
break
end
end
led_marquee.display_msg(pos, channel, "/"..colorchar..string.sub(msg, f)..string.rep(" ", skip + 1))
led_marquee.schedule_msg(pos, channel, "/"..colorchar..string.sub(msg, f)..string.rep(" ", skip + 1))
meta:set_int("index", f)
if not elapsed or elapsed < 0.2 then return false end
@ -213,6 +230,27 @@ led_marquee.decode_color = function(msg)
end
minetest.register_globalstep(function(dtime)
if dtime <= led_marquee.message_schedule_dtime
and (#led_marquee.scheduled_messages) > 0 then
led_marquee.display_msg(
led_marquee.scheduled_messages[1].pos,
led_marquee.scheduled_messages[1].channel,
led_marquee.scheduled_messages[1].msg
)
end
table.remove(led_marquee.scheduled_messages, 1)
end)
led_marquee.schedule_msg = function(pos, channel, msg)
local idx = #led_marquee.scheduled_messages
led_marquee.scheduled_messages[idx+1] = { pos=pos, channel=channel, msg=msg }
if idx >= led_marquee.message_schedule_size then
table.remove(led_marquee.scheduled_messages, 1)
end
end
led_marquee.display_msg = function(pos, channel, msg)
msg = string.sub(msg, 1, 6144).." "
if string.sub(msg,1,1) == string.char(255) then -- treat it as incoming UTF-8
@ -312,13 +350,13 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
led_marquee.set_timer(pos, 0)
msg = string.rep(" ", 2048)
meta:set_string("last_msg", msg)
led_marquee.display_msg(pos, channel, msg)
led_marquee.schedule_msg(pos, channel, msg)
meta:set_int("index", 1)
elseif msg == "allon" then
led_marquee.set_timer(pos, 0)
msg = string.rep(string.char(144), 2048)
meta:set_string("last_msg", msg)
led_marquee.display_msg(pos, channel, msg)
led_marquee.schedule_msg(pos, channel, msg)
meta:set_int("index", 1)
elseif msg == "start_scroll" then
local timeout = meta:get_int("timeout")
@ -327,8 +365,8 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
led_marquee.set_timer(pos, 0)
return
elseif string.sub(msg, 1, 12) == "scroll_speed" then
local timeout = tonumber(string.sub(msg, 13))
led_marquee.set_timer(pos, timeout)
local timeout = tonumber(string.sub(msg, 13)) or 0
led_marquee.set_timer(pos, math.max(timeout, led_marquee.message_minimum_time))
elseif string.sub(msg, 1, 11) == "scroll_step" then
local skip = tonumber(string.sub(msg, 12))
led_marquee.scroll_text(pos, nil, skip)
@ -343,7 +381,7 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
led_marquee.set_timer(pos, 0)
local last_msg = meta:get_string("last_msg")
meta:set_string("last_msg", msg)
led_marquee.display_msg(pos, channel, msg)
led_marquee.schedule_msg(pos, channel, msg)
if last_msg ~= msg then
meta:set_int("index", 1)
end
@ -358,7 +396,7 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
end
elseif msg and type(msg) == "number" then
meta:set_string("last_msg", tostring(msg))
led_marquee.display_msg(pos, channel, tostring(msg))
led_marquee.schedule_msg(pos, channel, tostring(msg))
meta:set_int("index", 1)
end
end
@ -369,23 +407,17 @@ for i = 31, 255 do
local groups = { cracky = 2, not_in_creative_inventory = 1}
local light = LIGHT_MAX-2
local description = S("LED marquee panel ("..i..")")
local tiles = {
{ name="led_marquee_base.png", color="white"},
{ name="led_marquee_leds_off.png", color="white"},
"led_marquee_char_"..i..".png",
}
local leds = "led_marquee_char_"..i..".png^[mask:led_marquee_leds_on.png"
if i == 31 then
tiles = {
{ name="led_marquee_base.png", color="white"},
{ name="led_marquee_leds_off.png", color="white"},
{
name = "led_marquee_char_31.png",
animation = {type = "vertical_frames", aspect_w = 32, aspect_h = 32, length = 0.75}
}
leds ={
name = "led_marquee_char_31.png^[mask:led_marquee_leds_on_cursor.png",
animation = {type = "vertical_frames", aspect_w = 32, aspect_h = 32, length = 0.75}
}
end
local wimage
if i == 32 then
groups = {cracky = 2}
light = nil
@ -397,7 +429,11 @@ for i = 31, 255 do
description = description,
drawtype = "mesh",
mesh = "led_marquee.obj",
tiles = tiles,
tiles = {
{ name = "led_marquee_base.png", color = "white" },
{ name = "led_marquee_leds_off.png", color = "white" }
},
overlay_tiles = { "", leds },
inventory_image = wimage,
wield_image = wimage,
palette="led_marquee_palette.png",

View File

@ -1 +1,2 @@
name = led_marquee
min_minetest_version = 5.2.0

View File

@ -21,10 +21,6 @@ v -0.500000 -0.453125 0.468750
v -0.500000 -0.453125 -0.468750
v -0.500000 -0.437500 -0.484375
v -0.500000 -0.437500 -0.500000
v 0.500000 -0.449125 -0.468750
v -0.500000 -0.449125 -0.468750
v -0.500000 -0.449125 0.468750
v 0.500000 -0.449125 0.468750
vt 0.681855 0.961799
vt 0.723891 0.992824
vt 0.723891 0.000000
@ -69,10 +65,6 @@ vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 1.0000 0.0000 0.0000
vn 0.0000 -1.0000 -0.0000
vn -1.0000 0.0000 0.0000
@ -106,7 +98,5 @@ f 7/26/8 6/38/8 19/19/8
f 19/19/6 6/38/6 5/20/6
f 15/22/6 10/39/6 9/23/6
f 8/25/7 17/40/7 16/24/7
g Cube_Cube_LEDs_Cube_Cube_LEDs_leds_off
g Cube_Cube_LEDs_Cube_Cube_LEDs_base_led_marquee_leds_off.png
f 1/41/6 2/42/6 3/43/6 4/44/6
g Cube_Cube_LEDs_Cube_Cube_LEDs_leds_on
f 21/45/6 22/46/6 23/47/6 24/48/6

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 B

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 B

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 495 B

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 B

After

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 B

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 B

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 B

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 424 B

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 492 B

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 441 B

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

After

Width:  |  Height:  |  Size: 81 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

After

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 473 B

After

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 B

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 445 B

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 B

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 447 B

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 B

After

Width:  |  Height:  |  Size: 81 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 568 B

After

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 B

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 B

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 B

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 B

After

Width:  |  Height:  |  Size: 81 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 B

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 81 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 B

After

Width:  |  Height:  |  Size: 75 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 314 B

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 323 B

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 362 B

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 B

After

Width:  |  Height:  |  Size: 71 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 B

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 B

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 B

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 77 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 438 B

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

After

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 81 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 77 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 B

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 319 B

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 B

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 B

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 B

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 465 B

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 B

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 408 B

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 B

After

Width:  |  Height:  |  Size: 98 B

Some files were not shown because too many files have changed in this diff Show More