commit 15d7e3277f63d9aa1320a973246e8729e4e30eb2 Author: Vanessa Dannenberg Date: Wed Aug 15 01:27:39 2018 -0400 Initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..801d59d --- /dev/null +++ b/LICENSE @@ -0,0 +1,191 @@ +(This file copied from Digilines mod) + +The LGPLv3 applies to all code in this project. +The WTFPL applies to textures and any other content in this project which is +not source code. + +============================================================= + +GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + + +============================================================= + + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0bad565 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# LED marquee mod + +*by Vanessa Dannenberg* + +This mod provides set of alphanumeric LED marquee panels, controlled by Mesecons' Digilines mod. + +Simply place a panel segment, 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 mod will try to display it. + +The panels 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 panel. + +Strings will be displayed to all panels in a lineup, so long as they all face the same way, starting from the panel the Lua Controller is connected to, going left to right. The other panels in the line do not need to be connected to anything - think of them as being connected together internally. Only the panel at the far left need be connected to the Lua Controller. + +The string will spread until either a panel 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 panel at all. + +Panels to the left of the connected one are ignored in the case of strings. + +You can put multiple lines of panels end to end to form independent displays, so long as the panels 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 - 129 range, whether part of a string or singularly is ignored. + +The panels also respond to these control messages: + +* "off", "colon" and "period" act the same as on the numeric panels. Note that neither a colon nor a period actually look all that great on a 15-segment + display, so use a classic panel 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. +* "off_multi" turns all panels in a lineup off +* "allon_multi" turns on all segments of all panels in a lineup. + +You can use "get" and "getstr" to read the one character from the first, connected panel. These messages will not read the other panels in the lineup. + +All panels emit a small amount of light when displaying something. + +The panels only mount on a wall. diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..2cec86e --- /dev/null +++ b/depends.txt @@ -0,0 +1,2 @@ +default +digilines diff --git a/description.txt b/description.txt new file mode 100644 index 0000000..cf4079a --- /dev/null +++ b/description.txt @@ -0,0 +1 @@ +This mod provides a simple LED marquee that accepts single characters, strings, and special control words via digilines. diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..db30567 --- /dev/null +++ b/init.lua @@ -0,0 +1,169 @@ +-- simple LED marquee mod +-- by Vanessa Dannenberg + +led_marquee = {} + +local S +if minetest.get_modpath("intllib") then + S = intllib.Getter() +else + S = function(s) return s end +end + +local marquee_cbox = { + type = "fixed", + fixed = { -16/32, -8/16, 15/32, 16/32, 8/16, 16/32 } +} + +-- 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", "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 + +-- the nodes: + +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, "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}) + 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_string = 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 + if string.len(msg) > 1 then + if msg == "off" then + minetest.swap_node(pos, { name = "led_marquee:char_32", param2 = node.param2}) + elseif msg == "colon" then + minetest.swap_node(pos, { name = "led_marquee:char_58", param2 = node.param2}) + elseif msg == "period" then + minetest.swap_node(pos, { name = "led_marquee:char_46", param2 = node.param2}) + elseif msg == "del" then + minetest.swap_node(pos, { name = "led_marquee:char_127", param2 = node.param2}) + elseif msg == "allon" then + minetest.swap_node(pos, { name = "led_marquee:char_128", param2 = node.param2}) + elseif msg == "cursor" then + minetest.swap_node(pos, { name = "led_marquee:char_129", param2 = node.param2}) + 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}) + 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,"led_marquee:char_(.+)"))) -- 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,"led_marquee:char_(.+)")))) + end + end + elseif msg and type(msg) == "number" then + if msg == 0 then + minetest.swap_node(pos, { name = "led_marquee:char_32", param2 = node.param2}) + elseif msg > 31 and alnum_chars[msg - 31] ~= nil then + minetest.swap_node(pos, { name = "led_marquee:char_"..tostring(msg), param2 = node.param2}) + end + end +end + +for i = 32, 129 do + local groups = { cracky = 2, not_in_creative_inventory = 1} + local light = LIGHT_MAX-2 + local description = S("Alphanumeric LED marquee panel ("..i..")") + + if i == 32 then + groups = {cracky = 2} + light = nil + description = S("Alphanumeric LED marquee panel") + end + + minetest.register_node("led_marquee:char_"..i, { + description = description, + drawtype = "mesh", + mesh = "led_marquee.obj", + tiles = { + "led_marquee_base.png", + "led_marquee_leds_off.png", + { name="led_marquee_char_"..i..".png", color="0xffff0000"}, + }, + use_texture_alpha = true, + groups = groups, + paramtype = "light", + paramtype2 = "colorfacedir", + light_source = light, + selection_box = marquee_cbox, + collision_box = marquee_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_string, + }, + }, + drop = "led_marquee:char_32" + }) +end + +-- crafts + + +minetest.register_craft({ + output = "led_marquee:char_32 4", + recipe = { + { "", "default:glass", "" }, + { "default:glass", "default:sign_wall", "default:glass" }, + { "default:glass", "default:mese_crystal", "default:glass" } + }, +}) + diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..804c48c --- /dev/null +++ b/mod.conf @@ -0,0 +1 @@ +name = led_marquee diff --git a/models/LED marquee.blend b/models/LED marquee.blend new file mode 100644 index 0000000..f84a96e Binary files /dev/null and b/models/LED marquee.blend differ diff --git a/models/LED marquee.blend1 b/models/LED marquee.blend1 new file mode 100644 index 0000000..0380274 Binary files /dev/null and b/models/LED marquee.blend1 differ diff --git a/models/led_marquee.obj b/models/led_marquee.obj new file mode 100644 index 0000000..c4d6f63 --- /dev/null +++ b/models/led_marquee.obj @@ -0,0 +1,98 @@ +# Blender v2.79 (sub 0) OBJ File: 'LED marquee.blend' +# www.blender.org +o Cube_Cube_LEDs +v 0.500000 -0.468750 0.453125 +v -0.500000 -0.468750 0.453125 +v -0.500000 0.468750 0.453125 +v 0.500000 0.468750 0.453125 +v 0.500000 -0.500000 0.437500 +v 0.500000 -0.484375 0.437500 +v 0.500000 -0.468750 0.453125 +v 0.500000 0.468750 0.453125 +v 0.500000 0.484375 0.437500 +v 0.500000 0.500000 0.437500 +v 0.500000 0.500000 0.500000 +v 0.500000 -0.500000 0.500000 +v -0.500000 0.500000 0.500000 +v -0.500000 -0.500000 0.500000 +v -0.500000 0.500000 0.437500 +v -0.500000 0.484375 0.437500 +v -0.500000 0.468750 0.453125 +v -0.500000 -0.468750 0.453125 +v -0.500000 -0.484375 0.437500 +v -0.500000 -0.500000 0.437500 +v 0.500000 -0.468750 0.449125 +v -0.500000 -0.468750 0.449125 +v -0.500000 0.468750 0.449125 +v 0.500000 0.468750 0.449125 +vt 0.667843 0.000000 +vt 0.667843 0.015513 +vt 0.681855 0.031026 +vt 0.681855 0.961799 +vt 0.667843 0.977312 +vt 0.667843 0.992824 +vt 0.723891 0.992824 +vt 0.723891 0.000000 +vt 1.000000 0.007175 +vt 1.000000 1.000000 +vt 0.103234 1.000000 +vt 0.103234 0.007175 +vt 0.723891 0.000000 +vt 0.723891 0.992824 +vt 0.667843 0.992824 +vt 0.667843 0.977312 +vt 0.681855 0.961799 +vt 0.681855 0.031026 +vt 0.667843 0.015513 +vt 0.667843 0.000000 +vt 0.003280 0.226388 +vt 0.900045 0.226388 +vt 0.900045 0.164337 +vt 0.003280 0.164337 +vt 0.900045 0.226388 +vt 0.003280 0.226388 +vt 0.003280 0.164337 +vt 0.900045 0.164337 +vt 1.000000 -0.000000 +vt 1.000000 0.017400 +vt 0.000000 0.017400 +vt 0.000000 -0.000000 +vt 1.000000 0.982506 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.982506 +vt 0.000000 0.965011 +vt 1.000000 0.965011 +vt 1.000000 0.034801 +vt 0.000000 0.034801 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vn 1.0000 0.0000 -0.0000 +vn 0.0000 -0.0000 1.0000 +vn -1.0000 -0.0000 0.0000 +vn 0.0000 -1.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn -0.0000 0.0000 -1.0000 +vn -0.0000 -0.7071 -0.7071 +vn -0.0000 0.7071 -0.7071 +g Cube_Cube_LEDs_Cube_Cube_LEDs_base +s off +f 5/1/1 6/2/1 7/3/1 8/4/1 9/5/1 10/6/1 11/7/1 12/8/1 +f 12/9/2 11/10/2 13/11/2 14/12/2 +f 14/13/3 13/14/3 15/15/3 16/16/3 17/17/3 18/18/3 19/19/3 20/20/3 +f 12/21/4 14/22/4 20/23/4 5/24/4 +f 13/25/5 11/26/5 10/27/5 15/28/5 +f 20/29/6 19/30/6 6/31/6 5/32/6 +f 16/33/6 15/34/6 10/35/6 9/36/6 +f 9/36/7 8/37/7 17/38/7 16/33/7 +f 18/39/8 7/40/8 6/31/8 19/30/8 +g Cube_Cube_LEDs_Cube_Cube_LEDs_leds_off +f 1/41/6 2/42/6 3/43/6 4/44/6 +g Cube_Cube_LEDs_Cube_Cube_LEDs_leds_on +f 21/45/6 22/46/6 23/47/6 24/48/6 diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..38523ac Binary files /dev/null and b/screenshot.png differ diff --git a/textures/led_marquee_base.png b/textures/led_marquee_base.png new file mode 100644 index 0000000..0629b20 Binary files /dev/null and b/textures/led_marquee_base.png differ diff --git a/textures/led_marquee_leds_off.png b/textures/led_marquee_leds_off.png new file mode 100644 index 0000000..82f3ea9 Binary files /dev/null and b/textures/led_marquee_leds_off.png differ