1
0
mirror of https://github.com/mt-mods/led_marquee.git synced 2025-07-15 14:50:35 +02:00

2 Commits

Author SHA1 Message Date
79bc4755dd Merge remote-tracking branch 'upstream/master' 2020-09-11 20:45:38 +02:00
b081594e2c Add loading message to action log 2020-07-23 16:01:08 +02:00
12 changed files with 38 additions and 63 deletions

View File

@ -1,10 +0,0 @@
name: luacheck
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: ""

View File

@ -1,11 +0,0 @@
unused_args = false
read_globals = {
table = {fields = {"copy"}},
"minetest",
"digilines"
}
globals = {
"led_marquee"
}

5
depends.txt Normal file
View File

@ -0,0 +1,5 @@
default
digilines
mesecons_luacontroller
mesecons_microcontroller?
mesecons_lamp?

1
description.txt Normal file
View File

@ -0,0 +1 @@
This mod provides a simple LED marquee that accepts single characters, strings, and special control words via digilines.

View File

@ -4,15 +4,18 @@
led_marquee = {}
led_marquee.scheduled_messages = {}
-- settings
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.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 = minetest.get_translator(minetest.get_current_modname())
local FS = function(...) return minetest.formspec_escape(S(...)) end
local S
if minetest.get_modpath("intllib") then
S = intllib.make_gettext_pair()
else
S = function(s) return s end
end
local color_to_char = {
"0",
@ -100,15 +103,24 @@ 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",
"formspec_version[4]"..
"size[8,4]"..
"button_exit[3,2.5;2,0.5;proceed;"..FS("Proceed").."]"..
"field[1.75,1.5;4.5,0.5;channel;"..FS("Channel")..";${channel}]"
)
minetest.get_meta(pos):set_string("formspec", "field[channel;Channel;${channel}]")
end
local on_digiline_receive_std = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local setchan = meta:get_string("channel")
if setchan ~= channel then return end
local num = tonumber(msg)
if msg == "colon" or msg == "period" or msg == "off" or (num and (num >= 0 and num <= 9)) then
minetest.swap_node(pos, { name = "led_marquee:marquee_"..msg, param2 = node.param2})
end
end
-- convert Lua's idea of a UTF-8 char to ISO-8859-1
-- first char is non-break space, 0xA0
local iso_chars=" ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
local get_iso = function(c)
local hb = string.byte(c,1) or 0
local lb = string.byte(c,2) or 0
@ -354,12 +366,11 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
local skip = tonumber(string.sub(msg, 12))
led_marquee.scroll_text(pos, nil, skip)
elseif msg == "get" then -- get the master panel's displayed char as ASCII numerical value
digilines.receptor_send(pos, digilines.rules.default, channel,
tonumber(string.match(minetest.get_node(pos).name,"led_marquee:char_(.+)")))
digilines.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 the last stored message
digilines.receptor_send(pos, digilines.rules.default, channel, meta:get_string("last_msg"))
digilines.receptor_send(pos, digiline.rules.default, channel, meta:get_string("last_msg"))
elseif msg == "getindex" then -- get the scroll index
digilines.receptor_send(pos, digilines.rules.default, channel, meta:get_int("index"))
digilines.receptor_send(pos, digiline.rules.default, channel, meta:get_int("index"))
else
msg = string.gsub(msg, "//", string.char(30))
led_marquee.set_timer(pos, 0)
@ -372,7 +383,7 @@ local on_digiline_receive_string = function(pos, node, channel, msg)
end
else
local asc = string.byte(msg)
if asc > 30 and asc < 256 then
if asc > 29 and asc < 256 then
minetest.swap_node(pos, { name = "led_marquee:char_"..asc, param2 = fdir + (last_color*8)})
meta:set_string("last_msg", tostring(msg))
meta:set_int("index", 1)
@ -389,8 +400,8 @@ end
for i = 31, 255 do
local groups = { cracky = 2, not_in_creative_inventory = 1}
local light = minetest.LIGHT_MAX-2
local description = S("LED marquee panel (@1)", i)
local light = LIGHT_MAX-2
local description = S("LED marquee panel ("..i..")")
local leds = "led_marquee_char_"..i..".png^[mask:led_marquee_leds_on.png"
if i == 31 then
@ -419,9 +430,9 @@ for i = 31, 255 do
},
overlay_tiles = { "", leds },
inventory_image = wimage,
is_ground_content = false,
wield_image = wimage,
palette="led_marquee_palette.png",
use_texture_alpha = true,
groups = groups,
paramtype = "light",
paramtype2 = "colorwallmounted",
@ -463,3 +474,4 @@ minetest.register_craft({
},
})
minetest.log("action", "[led_marquee] loaded.")

View File

@ -1,5 +0,0 @@
# textdomain: led_marquee
LED marquee panel (@1)=LED-Anzeigetafel (@1)
LED marquee panel=LED-Anzeigetafel
Proceed=Fortsetzen
Channel=Kanal

View File

@ -1,5 +0,0 @@
# textdomain: led_marquee
LED marquee panel (@1)=
LED marquee panel=
Proceed=
Channel=

View File

@ -1,6 +1,2 @@
name = led_marquee
title = LED marquee
description = This mod provides a simple LED marquee that accepts single characters, strings, and special control words via digilines.
depends = default, digilines
optional_depends = mesecons_luacontroller, mesecons_microcontroller, mesecons_lamp
min_minetest_version = 5.2.0

View File

Before

Width:  |  Height:  |  Size: 649 KiB

After

Width:  |  Height:  |  Size: 649 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 KiB

View File

@ -1,8 +0,0 @@
# Minimal marquee interval
led_marquee_message_minimum_time (Minimal marquee interval) float 0.5
# Marquee globalstep update interval
led_marquee_message_schedule_dtime (Marquee globalstep update interval) float 0.2
# Global message queue size
led_marquee_message_schedule_size (Global message queue size) int 10