diff --git a/README.md b/README.md index 4ca607b..3d643d2 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,30 @@ nixie_tubes mod by Vanessa Ezekowitz -This mod provides a set of classic Nixie tubes, controlled by Mesecons' +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 message to that channel from a Mesecons Lua Controller with either -a number 0-9, the word "colon", the word "period" or the word "off". The tube -will "light-up" the appropriate number or symbol, or turn off entirely. +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. + +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 alphanumeric tubes respond to characters from the standard 7-bit ASCII +character set, along with these 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. + +Any unrecognized word or symbol outside the 32-129 range is ignored. Tubes emit a small amount of light when displaying something. diff --git a/init.lua b/init.lua index b55cad2..02bfe05 100644 --- a/init.lua +++ b/init.lua @@ -37,7 +37,7 @@ local reset_meta = function(pos) minetest.get_meta(pos):set_string("formspec", "field[channel;Channel;${channel}]") end -local on_digiline_receive = function(pos, node, channel, msg) +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 @@ -91,11 +91,217 @@ for _,tube in ipairs(nixie_types) do digiline = { receptor = {}, effector = { - action = on_digiline_receive + action = on_digiline_receive_std }, }, drop = "nixie_tubes:tube_off" }) end +-- Alpha-numeric tubes (Burroughs B-7971 or similar) + +--[[ + +Map of display wires: + + --1------ + |\ |8 /| + 6| \ | / |2 + | 7\ | /9 | + | \|/ | +14--> ---- ---- <--10 + | /|\ | + |13/ | \11| + 5| / | \ |3 + |/ 12| \| + ------4-- + _ + --¯¯ ¯¯-- <--15 + +-- Wire positions in table: +-- char = { 1, 2, 3, 4, .... , 13, 14, 15 } + +]]-- + +local alnum_chars = { + { " ", { 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 } }, + { "#", { 0,1,1,1,0,0,0,1,0,1,0,1,0,1,0 } }, + { "$", { 1,0,1,1,0,1,0,1,0,1,0,1,0,1,0 } }, + { "%", { 0,0,1,0,0,1,0,0,1,0,0,0,1,0,0 } }, + { "&", { 1,0,0,1,1,0,1,0,1,0,1,0,0,1,0 } }, + { "'", { 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 } }, + { "(", { 0,0,0,0,0,0,0,0,1,0,1,0,0,0,0 } }, + { ")", { 0,0,0,0,0,0,1,0,0,0,0,0,1,0,0 } }, + { "*", { 0,0,0,0,0,0,1,1,1,0,1,1,1,0,0 } }, + { ",", { 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 } }, + { "-", { 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0 } }, + { ".", { 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0 } }, + { "/", { 0,0,0,0,0,0,0,0,1,0,0,0,1,0,0 } }, + { "0", { 1,1,1,1,1,1,0,0,1,0,0,0,1,0,0 } }, -- 48 + { "1", { 0,1,1,0,0,0,0,0,1,0,0,0,0,0,0 } }, + { "2", { 1,1,0,1,0,0,0,0,0,1,0,0,1,0,0 } }, + { "3", { 1,1,1,1,0,0,0,0,0,1,0,0,0,0,0 } }, + { "4", { 0,1,1,0,0,1,0,0,0,1,0,0,0,1,0 } }, + { "5", { 1,0,1,1,0,1,0,0,0,1,0,0,0,1,0 } }, + { "6", { 1,0,1,1,1,1,0,0,0,1,0,0,0,1,0 } }, + { "7", { 1,0,0,0,0,0,0,0,1,0,0,1,0,0,0 } }, + { "8", { 1,1,1,1,1,1,0,0,0,0,1,0,0,1,0 } }, + { "9", { 1,1,1,0,0,1,0,0,0,1,0,0,0,1,0 } }, + { ":", { 0,0,0,0,0,0,0,1,0,0,0,1,0,0,0 } }, -- 58 + { ";", { 0,0,0,0,0,0,0,1,0,0,0,0,1,0,0 } }, + { "<", { 0,0,0,0,0,0,0,0,1,0,1,0,0,1,0 } }, + { "=", { 0,0,0,1,0,0,0,0,0,1,0,0,0,1,0 } }, + { ">", { 0,0,0,0,0,0,1,0,0,1,0,0,1,0,0 } }, + { "?", { 1,1,0,0,0,0,0,0,0,1,0,1,0,0,0 } }, + { "@", { 1,1,0,1,1,1,0,1,0,1,0,0,0,0,0 } }, -- 64 + { "A", { 1,1,1,0,1,1,0,0,0,1,0,0,0,1,0 } }, + { "B", { 1,1,1,1,0,0,0,1,0,1,0,1,0,0,0 } }, + { "C", { 1,0,0,1,1,1,0,0,0,0,0,0,0,0,0 } }, + { "D", { 1,1,1,1,0,0,0,1,0,0,0,1,0,0,0 } }, + { "E", { 1,0,0,1,1,1,0,0,0,0,0,0,0,1,0 } }, + { "F", { 1,0,0,0,1,1,0,0,0,0,0,0,0,1,0 } }, + { "G", { 1,0,1,1,1,1,0,0,0,1,0,0,0,0,0 } }, + { "H", { 0,1,1,0,1,1,0,0,0,1,0,0,0,1,0 } }, + { "I", { 1,0,0,1,0,0,0,1,0,0,0,1,0,0,0 } }, + { "J", { 0,1,1,1,1,0,0,0,0,0,0,0,0,0,0 } }, + { "K", { 0,0,0,0,1,1,0,0,1,0,1,0,0,1,0 } }, + { "L", { 0,0,0,1,1,1,0,0,0,0,0,0,0,0,0 } }, + { "M", { 0,1,1,0,1,1,1,0,1,0,0,0,0,0,0 } }, + { "N", { 0,1,1,0,1,1,1,0,0,0,1,0,0,0,0 } }, + { "O", { 1,1,1,1,1,1,0,0,0,0,0,0,0,0,0 } }, + { "P", { 1,1,0,0,1,1,0,0,0,1,0,0,0,1,0 } }, + { "Q", { 1,1,1,1,1,1,0,0,0,0,1,0,0,0,0 } }, + { "R", { 1,1,0,0,1,1,0,0,0,1,1,0,0,1,0 } }, + { "S", { 1,0,1,1,0,1,0,0,0,1,0,0,0,1,0 } }, + { "T", { 1,0,0,0,0,0,0,1,0,0,0,1,0,0,0 } }, + { "U", { 0,1,1,1,1,1,0,0,0,0,0,0,0,0,0 } }, + { "V", { 0,0,0,0,1,1,0,0,1,0,0,0,1,0,0 } }, + { "W", { 0,1,1,0,1,1,0,0,0,0,1,0,1,0,0 } }, + { "X", { 0,0,0,0,0,0,1,0,1,0,1,0,1,0,0 } }, + { "Y", { 0,0,0,0,0,0,1,0,1,0,0,1,0,0,0 } }, + { "Z", { 1,0,0,1,0,0,0,0,1,0,0,0,1,0,0 } }, + { "[", { 1,0,0,1,1,1,0,0,0,0,0,0,0,0,0 } }, -- 91 + { "\\", { 0,0,0,0,0,0,1,0,0,0,1,0,0,0,0 } }, + { "]", { 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0 } }, + { "^", { 0,0,0,0,0,0,0,0,0,0,1,0,1,0,0 } }, + { "_", { 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0 } }, + { "`", { 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 } }, + { "a", { 1,1,1,1,0,0,0,0,0,1,0,0,1,0,0 } }, -- 97 + { "b", { 0,0,0,1,1,1,0,0,0,0,1,0,0,1,0 } }, + { "c", { 0,0,0,1,1,0,0,0,0,1,0,0,0,1,0 } }, + { "d", { 0,1,1,1,0,0,0,0,0,1,0,0,1,0,0 } }, + { "e", { 1,0,0,1,1,1,0,0,1,0,0,0,0,1,0 } }, + { "f", { 1,0,0,0,1,1,0,0,0,0,0,0,0,1,0 } }, + { "g", { 1,1,1,1,0,0,1,0,0,1,0,0,0,0,0 } }, + { "h", { 0,0,0,0,1,1,0,0,0,0,1,0,0,1,0 } }, + { "i", { 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 } }, + { "j", { 0,1,1,1,0,0,0,0,0,0,0,0,0,0,0 } }, + { "k", { 0,0,0,0,0,0,0,1,1,0,1,1,0,0,0 } }, + { "l", { 0,0,0,0,0,0,0,1,0,0,0,1,0,0,0 } }, + { "m", { 0,0,1,0,1,0,0,0,0,1,0,1,0,1,0 } }, + { "n", { 0,0,0,0,1,0,0,0,0,0,1,0,0,1,0 } }, + { "o", { 0,0,1,1,1,0,0,0,0,1,0,0,0,1,0 } }, + { "p", { 1,0,0,0,1,1,0,0,1,0,0,0,0,1,0 } }, + { "q", { 1,1,1,0,0,0,1,0,0,1,0,0,0,0,0 } }, + { "r", { 0,0,0,0,1,0,0,0,0,0,0,0,0,1,0 } }, + { "s", { 1,0,1,1,0,1,0,0,0,1,0,0,0,1,0 } }, + { "t", { 0,0,0,1,1,1,0,0,0,0,0,0,0,1,0 } }, + { "u", { 0,0,1,1,1,0,0,0,0,0,0,0,0,0,0 } }, + { "v", { 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0 } }, + { "w", { 0,0,1,0,1,0,0,0,0,0,1,0,1,0,0 } }, + { "x", { 0,0,0,0,0,0,1,0,1,0,1,0,1,0,0 } }, + { "y", { 0,0,0,0,0,0,1,0,1,0,0,0,1,0,0 } }, + { "z", { 1,0,0,1,0,0,0,0,1,0,0,0,1,0,0 } }, + { "{", { 1,0,0,1,0,0,1,0,0,0,0,0,1,1,0 } }, + { "|", { 0,0,0,0,0,0,0,1,0,0,0,1,0,0,0 } }, + { "}", { 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 +} + +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 then + local asc = string.byte(msg) or 32 + 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 and alnum_chars[asc] then + minetest.swap_node(pos, { name = "nixie_tubes:alnum_"..asc, param2 = node.param2}) + end + end +end + +for i in ipairs(alnum_chars) do + local char = alnum_chars[i][1] + local bits = alnum_chars[i][2] + + local groups = { cracky = 2, not_in_creative_inventory = 1} + local light = LIGHT_MAX-4 + local description = S("Alphanumeric Nixie Tube ("..char..")") + + local wires = "nixie_tube_alnum_wires.png" + for j = 1, 15 do + if bits[j] == 1 then + wires = wires.."^nixie_tube_alnum_seg_"..j..".png" + end + end + + if char == 32 then + groups = {cracky = 2} + light = nil + description = S("Alphanumeric Nixie Tube") + wires = "nixie_tube_alnum_wires.png" + end + + minetest.register_node("nixie_tubes:alnum_"..string.byte(char), { + description = description, + drawtype = "mesh", + mesh = "nixie_tube.obj", + tiles = { + "nixie_tube_base.png", + "nixie_tube_backing.png", + wires, + "nixie_tube_anode.png", + "nixie_tube_glass.png", + }, + use_texture_alpha = true, + groups = groups, + paramtype = "light", + paramtype2 = "facedir", + light_source = light, + selection_box = tube_cbox, + collision_box = tube_cbox, + on_construct = function(pos) + reset_meta(pos) + end, + on_receive_fields = function(pos, formname, fields, sender) + if (fields.channel) then + minetest.get_meta(pos):set_string("channel", fields.channel) + end + end, + digiline = { + receptor = {}, + effector = { + action = on_digiline_receive_alnum + }, + }, + drop = "nixie_tubes:alnum_32" + }) +end diff --git a/textures/nixie_tube_alnum_seg_1.png b/textures/nixie_tube_alnum_seg_1.png new file mode 100644 index 0000000..3cc70b0 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_1.png differ diff --git a/textures/nixie_tube_alnum_seg_10.png b/textures/nixie_tube_alnum_seg_10.png new file mode 100644 index 0000000..8b01a26 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_10.png differ diff --git a/textures/nixie_tube_alnum_seg_11.png b/textures/nixie_tube_alnum_seg_11.png new file mode 100644 index 0000000..0664dcb Binary files /dev/null and b/textures/nixie_tube_alnum_seg_11.png differ diff --git a/textures/nixie_tube_alnum_seg_12.png b/textures/nixie_tube_alnum_seg_12.png new file mode 100644 index 0000000..4739711 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_12.png differ diff --git a/textures/nixie_tube_alnum_seg_13.png b/textures/nixie_tube_alnum_seg_13.png new file mode 100644 index 0000000..92d4980 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_13.png differ diff --git a/textures/nixie_tube_alnum_seg_14.png b/textures/nixie_tube_alnum_seg_14.png new file mode 100644 index 0000000..8cfccb1 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_14.png differ diff --git a/textures/nixie_tube_alnum_seg_15.png b/textures/nixie_tube_alnum_seg_15.png new file mode 100644 index 0000000..61aeead Binary files /dev/null and b/textures/nixie_tube_alnum_seg_15.png differ diff --git a/textures/nixie_tube_alnum_seg_2.png b/textures/nixie_tube_alnum_seg_2.png new file mode 100644 index 0000000..34bd0a5 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_2.png differ diff --git a/textures/nixie_tube_alnum_seg_3.png b/textures/nixie_tube_alnum_seg_3.png new file mode 100644 index 0000000..94f95f2 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_3.png differ diff --git a/textures/nixie_tube_alnum_seg_4.png b/textures/nixie_tube_alnum_seg_4.png new file mode 100644 index 0000000..5b435d7 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_4.png differ diff --git a/textures/nixie_tube_alnum_seg_5.png b/textures/nixie_tube_alnum_seg_5.png new file mode 100644 index 0000000..3abdd45 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_5.png differ diff --git a/textures/nixie_tube_alnum_seg_6.png b/textures/nixie_tube_alnum_seg_6.png new file mode 100644 index 0000000..8d1f0a8 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_6.png differ diff --git a/textures/nixie_tube_alnum_seg_7.png b/textures/nixie_tube_alnum_seg_7.png new file mode 100644 index 0000000..9bcdcb1 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_7.png differ diff --git a/textures/nixie_tube_alnum_seg_8.png b/textures/nixie_tube_alnum_seg_8.png new file mode 100644 index 0000000..7668d42 Binary files /dev/null and b/textures/nixie_tube_alnum_seg_8.png differ diff --git a/textures/nixie_tube_alnum_seg_9.png b/textures/nixie_tube_alnum_seg_9.png new file mode 100644 index 0000000..30bf7db Binary files /dev/null and b/textures/nixie_tube_alnum_seg_9.png differ diff --git a/textures/nixie_tube_alnum_wires.png b/textures/nixie_tube_alnum_wires.png new file mode 100644 index 0000000..f993a8a Binary files /dev/null and b/textures/nixie_tube_alnum_wires.png differ