From a9d88e4b1cefe6be803832a6a1a4b72e00405dfb Mon Sep 17 00:00:00 2001 From: cheapie Date: Tue, 15 Dec 2015 14:42:58 -0600 Subject: [PATCH] Add _ALL_ the things! --- README | 22 +++++ depends.txt | 2 + init.lua | 174 ++++++++++++++++++++++++++++++++++ textures/digibutton_off.png | Bin 0 -> 444 bytes textures/digibutton_on.png | Bin 0 -> 459 bytes textures/digibutton_sides.png | Bin 0 -> 434 bytes textures/digimese.png | Bin 0 -> 565 bytes 7 files changed, 198 insertions(+) create mode 100644 README create mode 100644 depends.txt create mode 100644 init.lua create mode 100644 textures/digibutton_off.png create mode 100644 textures/digibutton_on.png create mode 100644 textures/digibutton_sides.png create mode 100644 textures/digimese.png diff --git a/README b/README new file mode 100644 index 0000000..6ed7c9c --- /dev/null +++ b/README @@ -0,0 +1,22 @@ +Digilines Button +================ + + +License: +Code - LGPL v3 or later (contains some code from mesecons and digilines) +Textures - CC BY-SA 3.0 Generic (contains modified versions of textures from mesecons and digilines) + + +Depends: +Required: digilines (base only) and mesecons (base only) +Only needed for craft recipes: default and mesecons_luacontroller + + +How to use digilines buttons: +Connect to a digiline (or digimese), right-click, and set a channel and message. +When the button is pressed (right-click), it will send that message on that channel, over digilines. +Note that the settings cannot be changed after setting - you must dig and re-place the button to do so. + + +How to use digimese: +It conducts digilines signals (like digilines) in all directions (like mese). That's about it, really. diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..5997a99 --- /dev/null +++ b/depends.txt @@ -0,0 +1,2 @@ +digilines +mesecons \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..8539e50 --- /dev/null +++ b/init.lua @@ -0,0 +1,174 @@ +digibutton = {} + +digibutton.button_turnoff = function (pos) + local node = minetest.get_node(pos) + if node.name=="digibutton:button_on" then --has not been dug + minetest.swap_node(pos, {name = "digibutton:button_off", param2=node.param2}) + minetest.sound_play("mesecons_button_pop", {pos=pos}) + end +end + +minetest.register_node("digibutton:digimese", { + description = "Digimese", + tiles = {"digimese.png"}, + paramtype = "light", + light_source = 3, + groups = {cracky = 3, level = 2}, + is_ground_content = false, + sounds = default.node_sound_stone_defaults(), + digiline = { wire = { rules = { + {x = 1, y = 0, z = 0}, + {x =-1, y = 0, z = 0}, + {x = 0, y = 1, z = 0}, + {x = 0, y =-1, z = 0}, + {x = 0, y = 0, z = 1}, + {x = 0, y = 0, z =-1}}}} +}) + +minetest.register_node("digibutton:button", { + drawtype = "nodebox", + tiles = { + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_off.png" + }, + paramtype = "light", + paramtype2 = "facedir", + legacy_wallmounted = true, + walkable = false, + sunlight_propagates = true, + selection_box = { + type = "fixed", + fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 } + }, + node_box = { + type = "fixed", + fixed = { + { -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the thin plate behind the button + { -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself + } + }, + digiline = + { + receptor = {} + }, + groups = {dig_immediate=2}, + description = "Digilines Button", + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec","size[8,4;]field[1,1;6,2;channel;Channel;${channel}]field[1,2;6,2;msg;Message;${msg}]button_exit[2.25,3;3,1;submit;Save]") + end, + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.get_meta(pos) + if fields.channel and fields.msg and fields.channel ~= "" and fields.msg ~= "" then + meta:set_string("channel",fields.channel) + meta:set_string("msg",fields.msg) + meta:set_string("formspec","") + minetest.swap_node(pos, {name = "digibutton:button_off", param2=minetest.get_node(pos).param2}) + else + minetest.chat_send_player(sender:get_player_name(),"Channel and message must both be set!") + end + end, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("digibutton:button_off", { + drawtype = "nodebox", + tiles = { + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_off.png" + }, + paramtype = "light", + paramtype2 = "facedir", + legacy_wallmounted = true, + walkable = false, + sunlight_propagates = true, + selection_box = { + type = "fixed", + fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 } + }, + node_box = { + type = "fixed", + fixed = { + { -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the thin plate behind the button + { -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself + } + }, + digiline = + { + receptor = {} + }, + groups = {dig_immediate=2, not_in_creative_inventory=1}, + drop = "digibutton:button", + description = "Digilines Button (off state - you hacker you!)", + on_rightclick = function (pos, node, clicker) + local meta = minetest.get_meta(pos) + digiline:receptor_send(pos, digiline.rules.default, meta:get_string("channel"), meta:get_string("msg")) + minetest.swap_node(pos, {name = "digibutton:button_on", param2=node.param2}) + minetest.sound_play("mesecons_button_push", {pos=pos}) + minetest.after(1, digibutton.button_turnoff, pos) + end, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("digibutton:button_on", { + drawtype = "nodebox", + tiles = { + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_sides.png", + "digibutton_on.png" + }, + paramtype = "light", + paramtype2 = "facedir", + legacy_wallmounted = true, + walkable = false, + light_source = default.LIGHT_MAX-7, + sunlight_propagates = true, + selection_box = { + type = "fixed", + fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 } + }, + node_box = { + type = "fixed", + fixed = { + { -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, + { -4/16, -2/16, 11/32, 4/16, 2/16, 6/16 } + } + }, + digiline = + { + receptor = {} + }, + groups = {dig_immediate=2, not_in_creative_inventory=1}, + drop = 'digibutton:button', + description = "Digilines Button (on state - you hacker you!)", + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_craft({ + output = "digibutton:digimese", + recipe = { + {"digilines:wire_std_00000000","digilines:wire_std_00000000","digilines:wire_std_00000000"}, + {"digilines:wire_std_00000000","default:mese","digilines:wire_std_00000000"}, + {"digilines:wire_std_00000000","digilines:wire_std_00000000","digilines:wire_std_00000000"} + } +}) + +minetest.register_craft({ + output = "digibutton:button", + recipe = { + {"mesecons_button:button_off"}, + {"mesecons_luacontroller:luacontroller0000"}, + {"digilines:wire_std_00000000"} + } +}) diff --git a/textures/digibutton_off.png b/textures/digibutton_off.png new file mode 100644 index 0000000000000000000000000000000000000000..9e4506b06b749365bf322cecd8bd71879fbfe027 GIT binary patch literal 444 zcmV;t0Ym~maF7JXww;d96sZ!D)(Qn72P^PB>DM}qF5?qPD z%N>6d%MQER?ZK5jGd^Q~Hhi|(+?h_Niip{v8Io9xTY?#8#$+-vfIPpDge2S@cW-_~ z5D`eC>$)Y_62Q#(w$(AdR!Wx|P%jp!&Bw#zRAVU-=wts0a!^y zK~y-)&5}KC6hRP$zpCo#fdI*S19J-kByNEN$7qEJxeQuy03tGg!jp3jTH2xLK`Msa_gLyq0r|O5`^2v6Ns%a}5E0Z`F*9<`Y`0sQ zoCfgUfQX=1Pn!dG!(*7nCJn}Ui1u09k9Y9@#2+IxoBV%MA%Fk?002ovPDHLkV1kjv B!qET# literal 0 HcmV?d00001 diff --git a/textures/digibutton_sides.png b/textures/digibutton_sides.png new file mode 100644 index 0000000000000000000000000000000000000000..9b79b574f1957271133a2446523a0a27bcd1b86b GIT binary patch literal 434 zcmV;j0ZsmiP)|+it`#2thjx%xjTBjN%y1a6yx;FuRa6zs3?c#%L3g97AR@?2m>Ieo=h=vWx;s=A0I>Il znE?Q*3IL$0^NI+n3fFZZBCyticQ-N{CD7e) zRYhh3zz|dwx*H;bh#1$qdjct@X7;arW`@1@1iJfVC1F*;-J#F(ATyDf*n5vzuh;7< zGktiT=X(zB`-ZB*-Qn(oSyf{!X_)$H0gfzqmT_h)xeka5_$kvm~do znaw80nVD$t=?4j>3mj1q88a!s_R^<_7*VGZYo|#RWBt5nyqPlxC+fMLCU!U0TG)Hf c4P|G30HESSfy%hjhX4Qo07*qoM6N<$g5zAasQ>@~ literal 0 HcmV?d00001 diff --git a/textures/digimese.png b/textures/digimese.png new file mode 100644 index 0000000000000000000000000000000000000000..aa6b97baf59f431161f1711a50b2b6dc81293d95 GIT binary patch literal 565 zcmV-50?Pe~P)2e>I-+%skaTwp3 zV^o&a0XRhEvxJTe2Lx5w_?Gsf&V=VH0mAq$jN7mfN~5VF z!s)0?bFQMOaEQ`WKA)^{-@kpQhzM~A=rJlH^`eN-cY-@ia|WutIoBqD%h~8m*!wIO znvI`zy%=5`cW0XSQ)k>9Qx&E;V|^!#n@xL&`c7C@CugTKC1?MjsVr;ZayI(Tu(D<3 z{>Tk|M==w2o9inD9V+)dnfe-26X+2CXCV$1c@NWWW3zm--vDx!ro;D?TU09@&uQ&2|@S=(PjP$R;Jn@00000NkvXXu0mjf D%DV8y literal 0 HcmV?d00001