Fix minor bugs and adapt mod to the new lcdlib mod

This commit is contained in:
Joachim Stolberg 2023-08-19 17:58:58 +02:00
parent 56b8e2bef6
commit 6b77916afa
8 changed files with 47 additions and 6 deletions

View File

@ -392,12 +392,16 @@ return {
"\n", "\n",
"Das Display zeigt nach dem Platzieren seine Nummer an. Über diese Nummer kann das Display angesprochen werden. Auf dem Display können Texte ausgegeben werden\\, wobei das Display 5 Zeilen und damit 5 unterschiedliche Texte darstellen kann.\n".. "Das Display zeigt nach dem Platzieren seine Nummer an. Über diese Nummer kann das Display angesprochen werden. Auf dem Display können Texte ausgegeben werden\\, wobei das Display 5 Zeilen und damit 5 unterschiedliche Texte darstellen kann.\n"..
"\n".. "\n"..
"Textzeilen werden immer linksbündig ausgegeben. Soll der Text horizontal zentriert ausgerichtet werden\\, muss dem Text das Zeichen „t“ (Tabulator) vorangestellt werden.\n"..
"\n"..
"Das Display wird maximal ein mal pro Sekunde aktualisiert.\n".. "Das Display wird maximal ein mal pro Sekunde aktualisiert.\n"..
"\n".. "\n"..
"\n".. "\n"..
"\n", "\n",
"Das TA4 Display XL hat die doppelte Größ wie das TA4 Display.\n".. "Das TA4 Display XL hat die doppelte Größ wie das TA4 Display.\n"..
"\n".. "\n"..
"Textzeilen werden immer linksbündig ausgegeben. Soll der Text horizontal zentriert ausgerichtet werden\\, muss dem Text das Zeichen „t“ (Tabulator) vorangestellt werden.\n"..
"\n"..
"Das Display wird maximal alle zwei Sekunden aktualisiert.\n".. "Das Display wird maximal alle zwei Sekunden aktualisiert.\n"..
"\n".. "\n"..
"\n".. "\n"..

View File

@ -390,12 +390,16 @@ return {
"\n", "\n",
"The display shows its number after placement. The display can be addressed via this number. Texts can be output on the display\\, whereby the display can display 5 lines and thus 5 different texts.\n".. "The display shows its number after placement. The display can be addressed via this number. Texts can be output on the display\\, whereby the display can display 5 lines and thus 5 different texts.\n"..
"\n".. "\n"..
"Lines of text are always left-aligned. If the text is to be centered horizontally\\, the text must be preceded by the character \"t\" (tabulator).\n"..
"\n"..
"The display is updated at most once per second.\n".. "The display is updated at most once per second.\n"..
"\n".. "\n"..
"\n".. "\n"..
"\n", "\n",
"The TA4 Display XL is twice the size of the TA4 display.\n".. "The TA4 Display XL is twice the size of the TA4 display.\n"..
"\n".. "\n"..
"Lines of text are always left-aligned. If the text is to be centered horizontally\\, the text must be preceded by the character \"t\" (tabulator).\n"..
"\n"..
"The display is updated every two seconds at most.\n".. "The display is updated every two seconds at most.\n"..
"\n".. "\n"..
"\n".. "\n"..

View File

@ -30,8 +30,8 @@ elseif minetest.global_exists("tubelib2") and tubelib2.version < 2.2 then
elseif minetest.global_exists("minecart") and minecart.version < 2.04 then elseif minetest.global_exists("minecart") and minecart.version < 2.04 then
minetest.log("error", "[techage] Techage requires minecart version 2.04 or newer!") minetest.log("error", "[techage] Techage requires minecart version 2.04 or newer!")
return return
elseif minetest.global_exists("lcdlib") and lcdlib.version < 1.01 then elseif minetest.global_exists("lcdlib") and lcdlib.version < 1.02 then
minetest.log("error", "[techage] Techage requires lcdlib version 1.01 or newer!") minetest.log("error", "[techage] Techage requires lcdlib version 1.02 or newer!")
return return
elseif minetest.global_exists("safer_lua") and safer_lua.version < 1.01 then elseif minetest.global_exists("safer_lua") and safer_lua.version < 1.01 then
minetest.log("error", "[techage] Techage requires safer_lua version 1.01 or newer!") minetest.log("error", "[techage] Techage requires safer_lua version 1.01 or newer!")

View File

@ -137,10 +137,9 @@ techage.lua_ctlr.register_action("display", {
row = tonumber(row or 1) or 1 row = tonumber(row or 1) or 1
text = tostring(text or "") text = tostring(text or "")
if not_protected(self.meta.owner, num) then if not_protected(self.meta.owner, num) then
if text:byte(1) ~= 32 then -- left aligned? if text:byte(1) == 32 then -- left aligned?
text = "<"..text -- use the '<' lcdlib control char for left-aligned -- use the '\t' lcdlib control char for left-aligned
else text = "\t" .. text:sub(2)
text = text:sub(2) -- delete blank for centered
end end
if row == 0 then -- add line? if row == 0 then -- add line?
techage.send_single(self.meta.number, num, "add", text) techage.send_single(self.meta.number, num, "add", text)
@ -161,6 +160,29 @@ techage.lua_ctlr.register_action("display", {
}) })
techage.lua_ctlr.register_action("display2", {
cmnd = function(self, num, row, text)
num = tostring(num or "")
row = tonumber(row or 1) or 1
text = tostring(text or "")
if not_protected(self.meta.owner, num) then
if row == 0 then -- add line?
techage.send_single(self.meta.number, num, "add", text)
else
local payload = safer_lua.Store()
payload.set("row", row)
payload.set("str", text)
techage.send_single(self.meta.number, num, "set", payload)
end
end
end,
help = " $display2(num, row, text)\n"..
" Alternative 'display' function with different\n"..
" control char. If the first char of the string\n"..
" is a '\t', the text will be horizontally centered."
})
techage.lua_ctlr.register_action("clear_screen", { techage.lua_ctlr.register_action("clear_screen", {
cmnd = function(self, num) cmnd = function(self, num)
num = tostring(num or "") num = tostring(num or "")

View File

@ -412,6 +412,8 @@ Die Batterie muss in unmittelbarer Nähe zum Controller platziert werden, also a
Das Display zeigt nach dem Platzieren seine Nummer an. Über diese Nummer kann das Display angesprochen werden. Auf dem Display können Texte ausgegeben werden, wobei das Display 5 Zeilen und damit 5 unterschiedliche Texte darstellen kann. Das Display zeigt nach dem Platzieren seine Nummer an. Über diese Nummer kann das Display angesprochen werden. Auf dem Display können Texte ausgegeben werden, wobei das Display 5 Zeilen und damit 5 unterschiedliche Texte darstellen kann.
Textzeilen werden immer linksbündig ausgegeben. Soll der Text horizontal zentriert ausgerichtet werden, muss dem Text das Zeichen „\t“ (Tabulator) vorangestellt werden.
Das Display wird maximal ein mal pro Sekunde aktualisiert. Das Display wird maximal ein mal pro Sekunde aktualisiert.
[ta4_display|image] [ta4_display|image]
@ -420,6 +422,8 @@ Das Display wird maximal ein mal pro Sekunde aktualisiert.
Das TA4 Display XL hat die doppelte Größ wie das TA4 Display. Das TA4 Display XL hat die doppelte Größ wie das TA4 Display.
Textzeilen werden immer linksbündig ausgegeben. Soll der Text horizontal zentriert ausgerichtet werden, muss dem Text das Zeichen „\t“ (Tabulator) vorangestellt werden.
Das Display wird maximal alle zwei Sekunden aktualisiert. Das Display wird maximal alle zwei Sekunden aktualisiert.
[ta4_displayXL|image] [ta4_displayXL|image]

View File

@ -403,6 +403,8 @@ The battery must be placed in close proximity to the controller, i.e. in one of
The display shows its number after placement. The display can be addressed via this number. Texts can be output on the display, whereby the display can display 5 lines and thus 5 different texts. The display shows its number after placement. The display can be addressed via this number. Texts can be output on the display, whereby the display can display 5 lines and thus 5 different texts.
Lines of text are always left-aligned. If the text is to be centered horizontally, the text must be preceded by the character "\t" (tabulator).
The display is updated at most once per second. The display is updated at most once per second.
[ta4_display|image] [ta4_display|image]
@ -411,6 +413,8 @@ The display is updated at most once per second.
The TA4 Display XL is twice the size of the TA4 display. The TA4 Display XL is twice the size of the TA4 display.
Lines of text are always left-aligned. If the text is to be centered horizontally, the text must be preceded by the character "\t" (tabulator).
The display is updated every two seconds at most. The display is updated every two seconds at most.
[ta4_displayXL|image] [ta4_displayXL|image]

View File

@ -119,6 +119,7 @@ minetest.register_node("techage:ta4_movecontroller", {
meta:set_string("status", S("Recording...")) meta:set_string("status", S("Recording..."))
local name = player:get_player_name() local name = player:get_player_name()
minetest.chat_send_player(name, S("Click on all blocks that shall be moved")) minetest.chat_send_player(name, S("Click on all blocks that shall be moved"))
mark.unmark_all(name)
mark.start(name, MAX_BLOCKS) mark.start(name, MAX_BLOCKS)
meta:set_string("formspec", formspec(nvm, meta)) meta:set_string("formspec", formspec(nvm, meta))
elseif fields.done then elseif fields.done then

View File

@ -91,6 +91,7 @@ minetest.register_node("techage:ta4_laser_emitter", {
end, end,
paramtype2 = "facedir", paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {choppy=2, cracky=2, crumbly=2}, groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
@ -121,6 +122,7 @@ minetest.register_node("techage:ta4_laser_receiver", {
end, end,
paramtype2 = "facedir", paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {choppy=2, cracky=2, crumbly=2}, groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),