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

8 Commits

Author SHA1 Message Date
d182766236 reduce color palette to 28 entries to make room for future control codes
(loses a dupe brown entry, and light blue and pink, which don't really work
well on a LED display)
2018-08-15 19:32:56 -04:00
09e5607d7a fix typo in docs 2018-08-15 19:17:39 -04:00
b9dd38c0de re-format palette to power-of-2 resolution 2018-08-15 19:05:05 -04:00
4fa6d54a4b fix undefined fdir in one spot
make some vars more readable
consolidate/cache fdir usage
2018-08-15 18:53:58 -04:00
157e517663 rename palette 2018-08-15 18:35:29 -04:00
e622f94dfc Merge branch 'led_marquee_gettext' into 'master'
Change intlib Getter (deprecated) to make_gettext_pair.

See merge request VanessaE/led_marquee!1
2018-08-15 22:13:43 +00:00
be7f72dfeb remove unused global 2018-08-15 18:12:35 -04:00
b33de7a530 Change intlib Getter (deprecated) to make_gettext_pair. 2018-08-15 10:09:30 -07:00
4 changed files with 34 additions and 33 deletions

View File

@ -40,13 +40,13 @@ The panels also respond to these control messages:
* "off_multi" turns all panels in a lineup off * "off_multi" turns all panels in a lineup off
* "allon_multi" turns on all LEDs of all panels in a lineup. * "allon_multi" turns on all LEDs of all panels in a lineup.
A byte value of 0 to 30 will change colors (i.e. string.char(0 to 30) ). Color values 0 to 11 are: A byte value of 0 to 27 will change colors (i.e. string.char(0 to 27) ). Color values 0 to 11 are:
Red (0), orange, yellow, lime, green, aqua, cyan, sky blue, blue, violet, magenta, or red-violet (11) Red (0), orange, yellow, lime, green, aqua, cyan, sky blue, blue, violet, magenta, or red-violet (11)
Colors 12 to 23 are the same as 0 to 11, but lower brightness. Colors 12 to 23 are the same as 0 to 11, but lower brightness.
Colors 23 - 30 are white, light grey, medium grey, dim grey, light blue, brown, and pink. Colors 24 - 27 are white, light grey, medium grey, and dim grey.
The left-most/"master" panel will remember the last color used, and defaults to red. The left-most/"master" panel will remember the last color used, and defaults to red.

View File

@ -1,11 +1,9 @@
-- simple LED marquee mod -- simple LED marquee mod
-- by Vanessa Dannenberg -- by Vanessa Dannenberg
led_marquee = {}
local S local S
if minetest.get_modpath("intllib") then if minetest.get_modpath("intllib") then
S = intllib.Getter() S = intllib.make_gettext_pair()
else else
S = function(s) return s end S = function(s) return s end
end end
@ -58,27 +56,29 @@ local display_string = function(pos, channel, string)
string = allon string = allon
end end
local padded_string = string.sub(string..padding, 1, 64) local padded_string = string.sub(string..padding, 1, 64)
local fdir = minetest.get_node(pos).param2 % 8 local master_fdir = minetest.get_node(pos).param2 % 8
local master_meta = minetest.get_meta(pos)
local last_color = master_meta:get_int("last_color")
local pos2 = pos local pos2 = pos
local mastermeta = minetest.get_meta(pos)
local lastcolor = mastermeta:get_int("lastcolor") if not last_color or last_color < 0 or last_color > 27 then
if not lastcolor or lastcolor < 0 or lastcolor > 30 then last_color = 0
lastcolor = 0 master_meta:set_int("last_color", 0)
mastermeta:set_int("lastcolor", 0)
end end
for i = 1, 64 do for i = 1, 64 do
local node = minetest.get_node(pos2) local node = minetest.get_node(pos2)
local fdir = node.param2 % 8
local meta = minetest.get_meta(pos2) local meta = minetest.get_meta(pos2)
local setchan = meta:get_string("channel") local setchan = meta:get_string("channel")
if not string.match(node.name, "led_marquee:char_") or (setchan ~= nil and setchan ~= "" and setchan ~= channel) then break end if not string.match(node.name, "led_marquee:char_") or (setchan ~= nil and setchan ~= "" and setchan ~= channel) then break end
local asc = string.byte(padded_string, i, i) local asc = string.byte(padded_string, i, i)
if (node.param2 % 8) == fdir and asc > 30 and asc < 256 then if master_fdir == fdir and asc > 30 and asc < 256 then
minetest.swap_node(pos2, { name = "led_marquee:char_"..asc, param2 = (node.param2 % 8) + (lastcolor*8)}) minetest.swap_node(pos2, { name = "led_marquee:char_"..asc, param2 = master_fdir + (last_color*8)})
pos2.x = pos2.x + fdir_to_right[fdir+1][1] pos2.x = pos2.x + fdir_to_right[fdir+1][1]
pos2.z = pos2.z + fdir_to_right[fdir+1][2] pos2.z = pos2.z + fdir_to_right[fdir+1][2]
elseif asc < 31 then elseif asc < 28 then
lastcolor = asc last_color = asc
mastermeta:set_int("lastcolor", asc) master_meta:set_int("last_color", asc)
end end
end end
end end
@ -86,37 +86,38 @@ end
local on_digiline_receive_string = function(pos, node, channel, msg) local on_digiline_receive_string = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local setchan = meta:get_string("channel") local setchan = meta:get_string("channel")
local lastcolor = meta:get_int("lastcolor") local last_color = meta:get_int("last_color")
if not lastcolor or lastcolor < 0 or lastcolor > 30 then if not last_color or last_color < 0 or last_color > 27 then
lastcolor = 0 last_color = 0
meta:set_int("lastcolor", 0) meta:set_int("last_color", 0)
end end
local fdir = node.param2 % 8
if setchan ~= channel then return end if setchan ~= channel then return end
if msg and msg ~= "" and type(msg) == "string" then if msg and msg ~= "" and type(msg) == "string" then
if string.len(msg) > 1 then if string.len(msg) > 1 then
if msg == "off" then if msg == "off" then
minetest.swap_node(pos, { name = "led_marquee:char_32", param2 = (node.param2 % 8) + (lastcolor*8)}) minetest.swap_node(pos, { name = "led_marquee:char_32", param2 = fdir + (last_color*8)})
elseif msg == "colon" then elseif msg == "colon" then
minetest.swap_node(pos, { name = "led_marquee:char_58", param2 = (node.param2 % 8) + (lastcolor*8)}) minetest.swap_node(pos, { name = "led_marquee:char_58", param2 = fdir + (last_color*8)})
elseif msg == "period" then elseif msg == "period" then
minetest.swap_node(pos, { name = "led_marquee:char_46", param2 = (node.param2 % 8) + (lastcolor*8)}) minetest.swap_node(pos, { name = "led_marquee:char_46", param2 = fdir + (last_color*8)})
elseif msg == "del" then elseif msg == "del" then
minetest.swap_node(pos, { name = "led_marquee:char_127", param2 = (node.param2 % 8) + (lastcolor*8)}) minetest.swap_node(pos, { name = "led_marquee:char_127", param2 = fdir + (last_color*8)})
elseif msg == "allon" then elseif msg == "allon" then
minetest.swap_node(pos, { name = "led_marquee:char_144", param2 = (node.param2 % 8) + (lastcolor*8)}) minetest.swap_node(pos, { name = "led_marquee:char_144", param2 = fdir + (last_color*8)})
elseif msg == "cursor" then elseif msg == "cursor" then
minetest.swap_node(pos, { name = "led_marquee:char_31", param2 = (node.param2 % 8) + (lastcolor*8)}) minetest.swap_node(pos, { name = "led_marquee:char_31", param2 = fdir + (last_color*8)})
else else
display_string(pos, channel, msg) display_string(pos, channel, msg)
end end
else else
local asc = string.byte(msg) local asc = string.byte(msg)
if asc > 30 and asc < 256 then if asc > 30 and asc < 256 then
minetest.swap_node(pos, { name = "led_marquee:char_"..asc, param2 = (node.param2 % 8) + (lastcolor*8)}) minetest.swap_node(pos, { name = "led_marquee:char_"..asc, param2 = fdir + (last_color*8)})
elseif asc < 31 then elseif asc < 28 then
lastcolor = asc last_color = asc
meta:set_int("lastcolor", asc) meta:set_int("last_color", asc)
elseif msg == "get" then -- get value as ASCII numerical value elseif msg == "get" then -- get value as ASCII numerical value
digiline:receptor_send(pos, digiline.rules.default, channel, tonumber(string.match(minetest.get_node(pos).name,"led_marquee:char_(.+)"))) -- wonderfully horrible string manipulaiton digiline:receptor_send(pos, digiline.rules.default, channel, tonumber(string.match(minetest.get_node(pos).name,"led_marquee:char_(.+)"))) -- wonderfully horrible string manipulaiton
elseif msg == "getstr" then -- get actual char elseif msg == "getstr" then -- get actual char
@ -125,9 +126,9 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
end end
elseif msg and type(msg) == "number" then elseif msg and type(msg) == "number" then
if msg == 0 then if msg == 0 then
minetest.swap_node(pos, { name = "led_marquee:char_32", param2 = (node.param2 % 8) + (lastcolor*8)}) minetest.swap_node(pos, { name = "led_marquee:char_32", param2 = fdir + (last_color*8)})
elseif msg > 30 then elseif msg > 30 then
minetest.swap_node(pos, { name = "led_marquee:char_"..tostring(msg), param2 = (node.param2 % 8) + (lastcolor*8)}) minetest.swap_node(pos, { name = "led_marquee:char_"..tostring(msg), param2 = fdir + (last_color*8)})
end end
end end
end end
@ -164,7 +165,7 @@ for i = 31, 255 do
drawtype = "mesh", drawtype = "mesh",
mesh = "led_marquee.obj", mesh = "led_marquee.obj",
tiles = tiles, tiles = tiles,
palette="palette.png", palette="led_marquee_palette.png",
use_texture_alpha = true, use_texture_alpha = true,
groups = groups, groups = groups,
paramtype = "light", paramtype = "light",

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 B