mirror of
https://github.com/mt-mods/led_marquee.git
synced 2025-06-29 23:00:56 +02:00
31-color support
This commit is contained in:
32
init.lua
32
init.lua
@ -12,7 +12,7 @@ end
|
||||
|
||||
local marquee_cbox = {
|
||||
type = "fixed",
|
||||
fixed = { -16/32, -8/16, 15/32, 16/32, 8/16, 16/32 }
|
||||
fixed = { -16/32, -8/16, -16/32, 16/32, 8/16, -15/32 }
|
||||
}
|
||||
|
||||
-- the following functions based on the so-named ones in Jeija's digilines mod
|
||||
@ -54,7 +54,7 @@ local display_string = function(pos, channel, string)
|
||||
string = allon
|
||||
end
|
||||
local padded_string = string.sub(string..padding, 1, 64)
|
||||
local fdir = minetest.get_node(pos).param2 % 4
|
||||
local fdir = minetest.get_node(pos).param2 % 8
|
||||
local pos2 = pos
|
||||
local mastermeta = minetest.get_meta(pos)
|
||||
local lastcolor = mastermeta:get_int("lastcolor")
|
||||
@ -69,11 +69,11 @@ local display_string = function(pos, channel, string)
|
||||
|
||||
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)
|
||||
if (node.param2 % 4) == fdir and asc > 31 and asc < 130 then
|
||||
minetest.swap_node(pos2, { name = "led_marquee:char_"..asc, param2 = (node.param2 % 4) + (lastcolor*32)})
|
||||
if (node.param2 % 8) == fdir and asc > 31 and asc < 130 then
|
||||
minetest.swap_node(pos2, { name = "led_marquee:char_"..asc, param2 = (node.param2 % 8) + (lastcolor*8)})
|
||||
pos2.x = pos2.x + fdir_to_right[fdir+1][1]
|
||||
pos2.z = pos2.z + fdir_to_right[fdir+1][2]
|
||||
elseif asc < 8 then
|
||||
elseif asc < 31 then
|
||||
lastcolor = asc
|
||||
mastermeta:set_int("lastcolor", asc)
|
||||
end
|
||||
@ -93,25 +93,25 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
|
||||
if msg and msg ~= "" and type(msg) == "string" then
|
||||
if string.len(msg) > 1 then
|
||||
if msg == "off" then
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_32", param2 = (node.param2 % 4) + (lastcolor*32)})
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_32", param2 = (node.param2 % 8) + (lastcolor*8)})
|
||||
elseif msg == "colon" then
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_58", param2 = (node.param2 % 4) + (lastcolor*32)})
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_58", param2 = (node.param2 % 8) + (lastcolor*8)})
|
||||
elseif msg == "period" then
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_46", param2 = (node.param2 % 4) + (lastcolor*32)})
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_46", param2 = (node.param2 % 8) + (lastcolor*8)})
|
||||
elseif msg == "del" then
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_127", param2 = (node.param2 % 4) + (lastcolor*32)})
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_127", param2 = (node.param2 % 8) + (lastcolor*8)})
|
||||
elseif msg == "allon" then
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_128", param2 = (node.param2 % 4) + (lastcolor*32)})
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_128", param2 = (node.param2 % 8) + (lastcolor*8)})
|
||||
elseif msg == "cursor" then
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_129", param2 = (node.param2 % 4) + (lastcolor*32)})
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_129", param2 = (node.param2 % 8) + (lastcolor*8)})
|
||||
else
|
||||
display_string(pos, channel, msg)
|
||||
end
|
||||
else
|
||||
local asc = string.byte(msg)
|
||||
if asc > 31 and asc < 130 then
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_"..asc, param2 = (node.param2 % 4) + (lastcolor*32)})
|
||||
elseif asc < 8 then
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_"..asc, param2 = (node.param2 % 8) + (lastcolor*8)})
|
||||
elseif asc < 31 then
|
||||
lastcolor = asc
|
||||
meta:set_int("lastcolor", asc)
|
||||
elseif msg == "get" then -- get value as ASCII numerical value
|
||||
@ -122,9 +122,9 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
|
||||
end
|
||||
elseif msg and type(msg) == "number" then
|
||||
if msg == 0 then
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_32", param2 = (node.param2 % 4) + (lastcolor*32)})
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_32", param2 = (node.param2 % 8) + (lastcolor*8)})
|
||||
elseif msg > 31 and alnum_chars[msg - 31] ~= nil then
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_"..tostring(msg), param2 = (node.param2 % 4) + (lastcolor*32)})
|
||||
minetest.swap_node(pos, { name = "led_marquee:char_"..tostring(msg), param2 = (node.param2 % 8) + (lastcolor*8)})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -165,7 +165,7 @@ for i = 32, 129 do
|
||||
use_texture_alpha = true,
|
||||
groups = groups,
|
||||
paramtype = "light",
|
||||
paramtype2 = "colorfacedir",
|
||||
paramtype2 = "colorwallmounted",
|
||||
light_source = light,
|
||||
selection_box = marquee_cbox,
|
||||
collision_box = marquee_cbox,
|
||||
|
Reference in New Issue
Block a user