summaryrefslogtreecommitdiff
path: root/nixie_tubes
diff options
context:
space:
mode:
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2018-08-15 18:15:28 -0400
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2018-08-15 18:15:28 -0400
commitdc0908e5fa86334226c982877e71aec8cfaf92ce (patch)
tree6fef541a45caed83f673b6411bf0888ee35dc4c4 /nixie_tubes
parent1adee001dd438172cd4ff7e3c6e9ca168b0bdd58 (diff)
downloaddreambuilder_modpack-dc0908e5fa86334226c982877e71aec8cfaf92ce.tar
dreambuilder_modpack-dc0908e5fa86334226c982877e71aec8cfaf92ce.tar.gz
dreambuilder_modpack-dc0908e5fa86334226c982877e71aec8cfaf92ce.tar.bz2
dreambuilder_modpack-dc0908e5fa86334226c982877e71aec8cfaf92ce.tar.xz
dreambuilder_modpack-dc0908e5fa86334226c982877e71aec8cfaf92ce.zip
update plantlife, farming_redo, nixie tubes
add my led_marquee mod
Diffstat (limited to 'nixie_tubes')
-rw-r--r--nixie_tubes/README.md36
-rw-r--r--nixie_tubes/init.lua87
2 files changed, 92 insertions, 31 deletions
diff --git a/nixie_tubes/README.md b/nixie_tubes/README.md
index 46b6f39..34a0a10 100644
--- a/nixie_tubes/README.md
+++ b/nixie_tubes/README.md
@@ -1,32 +1,50 @@
# nixie_tubes mod
-*by Vanessa Ezekowitz*
+*by Vanessa Dannenberg*
This mod provides a set of classic Nixie tubes, and a set of alphanumeric 15-segment tubes similar to Burroughs B-7971, controlled by Mesecons' Digilines mod.
Simply place a tube, right-click it, and set a channel.
-Then send a character or one of several control words to that channel from a Mesecons Lua Controller and the tube will try to display it.
+Then send a character, or one of several control words to that channel from a Mesecons Lua Controller and the mod will try to display it.
-The classic tubes are numeric with colon and period symbols, and hence will respond to the literal numbers 0-9, and the words "colon", "period", and "off". Any other symbol or word is ignored.
+The classic tubes are numeric with colon and period symbols, and hence will respond to the literal numbers 0-9, and the words "colon", "period", and "off". Any other symbol or string is ignored.
-The alphanumeric tubes respond to characters from the standard 7-bit ASCII character set, along with these messages:
+The alphanumeric tubes respond to singular characters from the standard 7-bit ASCII character set, or entire strings composed of such.
+
+A single character will be displayed on the connected tube. A decimal value as a numeric message (i.e. not a string) will display the first digit on the connected tube.
+
+Strings will be displayed to all alphanumeric tubes in a lineup, so long as they all face the same way, starting from the tube the Lua Controller is connected to, going left to right. The other tubes in the line do not need to be connected to anything - think of them as being connected together internally. Only the tube at the far left need be connected to the Lua Controller.
+
+The string will spread until either a tube is found that faces the wrong way, or has a channel that's not empty/nil and is set to something other than what the first is set to, or if a node is encountered that is not an alpha-numeric tube at all.
+
+Tubes to the left of the connected one are ignored in the case of strings.
+
+You can put multiple lines of tubes end to end to form independent displays, so long as the tubes that start each of the lines have unique channel names set.
+
+The string is padded with spaces and then trimmed to 64 characters.
+
+Any unrecognized symbol or character outside the ASCII 32 - 128 range, or characters 31 and 144, whether part of a string or singularly is ignored.
+
+The alphanumeric tubes also respond to these control messages:
* "off", "colon" and "period" act the same as on the numeric tubes. Note that neither a colon nor a period actually look all that great on a 15-segment
display, so use a classic tube for those, if you can.
* "del" or character code 127 displays an all-on square, but without segment #15 (the bottom, chevron-shaped one).
-* "allon" or character code 128 will display an all-on square, with segment #15 lit also.
-* "cursor" or character code 129 will display just segment 15.
+* "allon" or character code 144 will display an all-on square, with segment #15 lit also.
+* "cursor" or character code 31 will display just segment 15.
+* "off_multi" turns all tubes in a lineup off
+* "allon_multi" turns on all segments of all tubes in a lineup.
-Any unrecognized word or symbol outside the 32-129 range is ignored.
+You can use "get" and "getstr" to read the one character from the first, connected tube. These messages will not read the other tubes in the lineup.
-The Decatron tubes respond to 0-9 and "off", same as the others, along with the following actions:
+This mod also provides Decatron tubes, which respond to 0-9 and "off", just as with the classic numeric tubes, along with the following actions:
* "inc" will increment the tube's current number value. If the value overflows from 9 back to 0, the tube will generate a "carry" message.
* "dec" will decrement the current value. If the value wraps from 0 back to 9, the tube will send out a "borrow" message.
* "get" will query the current state of the tube, responding with a single digit 0-9 or the word "off".
-Tubes emit a small amount of light when displaying something.
+All tubes emit a small amount of light when displaying something.
Nixies can only be mounted on the floor, while Decatrons can be mounted on a wall (or a ceiling if so desired).
diff --git a/nixie_tubes/init.lua b/nixie_tubes/init.lua
index 7f10e5b..436b73a 100644
--- a/nixie_tubes/init.lua
+++ b/nixie_tubes/init.lua
@@ -250,6 +250,7 @@ Map of display wires:
]]--
local alnum_chars = {
+ { string.char(31), { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } }, -- "cursor" segment
{ " ", { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } }, -- 32
{ "!", { 0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 } },
{ '"', { 0,0,0,0,0,1,0,1,0,0,0,0,0,0,0 } },
@@ -346,39 +347,81 @@ local alnum_chars = {
{ "}", { 1,0,0,1,0,0,0,0,1,1,1,0,0,0,0 } },
{ "~", { 0,1,0,0,0,1,1,0,0,1,0,0,0,0,0 } },
{ string.char(127), { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 } }, -- "DEL"
- { string.char(128), { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } }, -- all-on
- { string.char(129), { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } }, -- "cursor" segment
+ { string.char(144), { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } }, -- all-on
}
+local fdir_to_right = {
+ { 1, 0 },
+ { 0, -1 },
+ { -1, 0 },
+ { 0, 1 },
+}
+
+local padding = " "
+local allon = string.char(128)
+for i = 1, 64 do
+ padding = padding.." "
+ allon = allon..string.char(128)
+end
+
+local display_string = function(pos, channel, string)
+ if string == "off_multi" then
+ string = ""
+ elseif string == "allon_multi" then
+ string = allon
+ end
+ local padded_string = string.sub(string..padding, 1, 64)
+ local fdir = minetest.get_node(pos).param2 % 4
+ local pos2 = pos
+ for i = 1, 64 do
+ local node = minetest.get_node(pos2)
+ local meta = minetest.get_meta(pos2)
+ local setchan = meta:get_string("channel")
+ if not string.match(node.name, "nixie_tubes:alnum_") or (setchan ~= nil and setchan ~= "" and setchan ~= channel) then break end
+ local asc = string.byte(padded_string, i, i)
+ if node.param2 == fdir and ((asc > 30 and asc < 128) or asc == 144) then
+ minetest.swap_node(pos2, { name = "nixie_tubes:alnum_"..asc, param2 = node.param2})
+ end
+ pos2.x = pos2.x + fdir_to_right[fdir+1][1]
+ pos2.z = pos2.z + fdir_to_right[fdir+1][2]
+ end
+end
+
local on_digiline_receive_alnum = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local setchan = meta:get_string("channel")
if setchan ~= channel then return end
if msg and msg ~= "" and type(msg) == "string" then
- local asc = string.byte(msg)
- if msg == "off" then
- minetest.swap_node(pos, { name = "nixie_tubes:alnum_32", param2 = node.param2})
- elseif msg == "colon" then
- minetest.swap_node(pos, { name = "nixie_tubes:alnum_58", param2 = node.param2})
- elseif msg == "period" then
- minetest.swap_node(pos, { name = "nixie_tubes:alnum_46", param2 = node.param2})
- elseif msg == "del" then
- minetest.swap_node(pos, { name = "nixie_tubes:alnum_127", param2 = node.param2})
- elseif msg == "allon" then
- minetest.swap_node(pos, { name = "nixie_tubes:alnum_128", param2 = node.param2})
- elseif msg == "cursor" then
- minetest.swap_node(pos, { name = "nixie_tubes:alnum_129", param2 = node.param2})
- elseif asc > 31 and alnum_chars[asc - 31] then
- minetest.swap_node(pos, { name = "nixie_tubes:alnum_"..asc, param2 = node.param2})
- 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,"nixie_tubes:alnum_(.+)"))) -- wonderfully horrible string manipulaiton
- elseif msg == "getstr" then -- get actual char
- digiline:receptor_send(pos, digiline.rules.default, channel, string.char(tonumber(string.match(minetest.get_node(pos).name,"nixie_tubes:alnum_(.+)"))))
+ if string.len(msg) > 1 then
+ if msg == "off" then
+ minetest.swap_node(pos, { name = "nixie_tubes:alnum_32", param2 = node.param2})
+ elseif msg == "colon" then
+ minetest.swap_node(pos, { name = "nixie_tubes:alnum_58", param2 = node.param2})
+ elseif msg == "period" then
+ minetest.swap_node(pos, { name = "nixie_tubes:alnum_46", param2 = node.param2})
+ elseif msg == "del" then
+ minetest.swap_node(pos, { name = "nixie_tubes:alnum_127", param2 = node.param2})
+ elseif msg == "allon" then
+ minetest.swap_node(pos, { name = "nixie_tubes:alnum_144", param2 = node.param2})
+ elseif msg == "cursor" then
+ minetest.swap_node(pos, { name = "nixie_tubes:alnum_31", param2 = node.param2})
+ else
+ display_string(pos, channel, msg)
+ end
+ else
+ local asc = string.byte(msg)
+ if (asc > 30 and asc < 128) or asc == 144 then
+ minetest.swap_node(pos, { name = "nixie_tubes:alnum_"..asc, param2 = node.param2})
+ 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,"nixie_tubes:alnum_(.+)"))) -- wonderfully horrible string manipulaiton
+ elseif msg == "getstr" then -- get actual char
+ digiline:receptor_send(pos, digiline.rules.default, channel, string.char(tonumber(string.match(minetest.get_node(pos).name,"nixie_tubes:alnum_(.+)"))))
+ end
end
elseif msg and type(msg) == "number" then
if msg == 0 then
minetest.swap_node(pos, { name = "nixie_tubes:alnum_32", param2 = node.param2})
- elseif msg > 31 and alnum_chars[msg - 31] ~= nil then
+ elseif (msg > 30 and msg < 128) or msg == 144 then
minetest.swap_node(pos, { name = "nixie_tubes:alnum_"..tostring(msg), param2 = node.param2})
end
end