From ff236643afc815f42f41e2b7524dac385e25c817 Mon Sep 17 00:00:00 2001 From: cheapie Date: Sat, 1 Sep 2018 07:12:16 -0500 Subject: [PATCH] Add dimmable lamp and junction box --- depends.txt | 1 + init.lua | 125 +++++++++++++++++++++++++++-- textures/digistuff_junctionbox.png | Bin 0 -> 4889 bytes textures/digistuff_light.png | Bin 0 -> 181 bytes 4 files changed, 119 insertions(+), 7 deletions(-) create mode 100644 textures/digistuff_junctionbox.png create mode 100644 textures/digistuff_light.png diff --git a/depends.txt b/depends.txt index 39f4fe0..a581a9b 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,3 @@ +default? digilines mesecons? diff --git a/init.lua b/init.lua index 351fb6b..0eb753f 100644 --- a/init.lua +++ b/init.lua @@ -360,7 +360,7 @@ minetest.register_node("digistuff:digimese", { light_source = 3, groups = {cracky = 3, level = 2}, is_ground_content = false, - sounds = default.node_sound_stone_defaults(), + sounds = default and default.node_sound_stone_defaults(), digiline = { wire = { rules = { {x = 1, y = 0, z = 0}, {x =-1, y = 0, z = 0}, @@ -417,7 +417,7 @@ minetest.register_node("digistuff:button", { minetest.chat_send_player(sender:get_player_name(),"Channel and message must both be set!") end end, - sounds = default.node_sound_stone_defaults(), + sounds = default and default.node_sound_stone_defaults(), }) minetest.register_node("digistuff:button_off", { @@ -460,7 +460,7 @@ minetest.register_node("digistuff:button_off", { if minetest.get_modpath("mesecons") then minetest.sound_play("mesecons_button_push", {pos=pos}) end minetest.after(0.5, digistuff.button_turnoff, pos) end, - sounds = default.node_sound_stone_defaults(), + sounds = default and default.node_sound_stone_defaults(), }) minetest.register_node("digistuff:button_on", { @@ -477,7 +477,7 @@ minetest.register_node("digistuff:button_on", { paramtype2 = "facedir", legacy_wallmounted = true, walkable = false, - light_source = default.LIGHT_MAX-7, + light_source = 7, sunlight_propagates = true, selection_box = { type = "fixed", @@ -502,7 +502,7 @@ minetest.register_node("digistuff:button_on", { if minetest.get_modpath("mesecons") then minetest.sound_play("mesecons_button_push", {pos=pos}) end end, description = "Digilines Button (on state - you hacker you!)", - sounds = default.node_sound_stone_defaults(), + sounds = default and default.node_sound_stone_defaults(), }) minetest.register_craft({ @@ -553,7 +553,7 @@ minetest.register_node("digistuff:detector", { if fields.msg then meta:set_string("msg",fields.msg) end if fields.radius then meta:set_string("radius",fields.radius) end end, - sounds = default.node_sound_stone_defaults() + sounds = default and default.node_sound_stone_defaults() }) minetest.register_abm({ @@ -877,7 +877,7 @@ minetest.register_node("digistuff:camera", { if fields.distance and tonumber(fields.distance) then meta:set_int("distance",math.max(math.min(20,fields.distance),0)) end if fields.radius and tonumber(fields.radius) then meta:set_int("radius",math.max(math.min(10,fields.radius),1)) end end, - sounds = default.node_sound_stone_defaults() + sounds = default and default.node_sound_stone_defaults() }) minetest.register_abm({ @@ -989,3 +989,114 @@ if minetest.get_modpath("mesecons_noteblock") then }, }) end + +for i=0,14,1 do + local mult = 255 - ((14-i)*16) + minetest.register_node("digistuff:light_"..i, { + drop = "digistuff:light_0", + description = "Digilines Dimmable Light"..(i > 0 and " (on state - you hacker you!)" or ""), + tiles = {"digistuff_light.png"}, + paramtype = "light", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.25,0.4,-0.25,0.25,0.5,0.25}, + } + }, + groups = i > 0 and {cracky = 1, not_in_creative_inventory = 1} or {cracky = 1}, + is_ground_content = false, + light_source = i, + color = {r = mult,g = mult,b = mult}, + sounds = default and default.node_sound_glass_defaults(), + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec","field[channel;Channel;${channel}") + end, + on_receive_fields = function(pos, formname, fields, sender) + local name = sender:get_player_name() + if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then + minetest.record_protection_violation(pos,name) + return + end + local meta = minetest.get_meta(pos) + if fields.channel then meta:set_string("channel",fields.channel) end + end, + digiline = { + receptor = {}, + wire = { + rules = { + {x = 1,y = 0,z = 0}, + {x = -1,y = 0,z = 0}, + {x = 0,y = 0,z = 1}, + {x = 0,y = 0,z = -1}, + {x = 0,y = 1,z = 0}, + {x = 0,y = -1,z = 0}, + {x = 0,y = 2,z = 0}, + } + }, + effector = { + action = function(pos,node,channel,msg) + local meta = minetest.get_meta(pos) + if meta:get_string("channel") ~= channel then return end + if type(msg) ~= "number" or msg > 14 or msg < 0 then return end + node.name = "digistuff:light_"..math.floor(msg) + minetest.swap_node(pos,node) + end + }, + }, + }) +end + +minetest.register_node("digistuff:junctionbox", { + description = "Digilines Junction Box", + tiles = {"digistuff_junctionbox.png"}, + paramtype = "light", + paramtype2 = "facedir", + groups = {cracky = 3}, + is_ground_content = false, + paramtype = "light", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.1,-0.15,0.35,0.1,0.15,0.5}, + } + }, + sounds = default and default.node_sound_stone_defaults(), + digiline = { + receptor = {}, + wire = { + rules = { + {x = 1,y = 0,z = 0}, + {x = -1,y = 0,z = 0}, + {x = 0,y = 0,z = 1}, + {x = 0,y = 0,z = -1}, + {x = 0,y = 1,z = 0}, + {x = 0,y = -1,z = 0}, + {x = 0,y = -2,z = 0}, + {x = 0,y = 2,z = 0}, + {x = -2,y = 0,z = 0}, + {x = 2,y = 0,z = 0}, + {x = 0,y = 0,z = -2}, + {x = 0,y = 0,z = 2}, + } + }, + }, +}) + +minetest.register_craft({ + output = "digistuff:light_0", + recipe = { + {"digilines:wire_std_00000000","mesecons_lamp:lamp_off",}, + } +}) + +minetest.register_craft({ + output = "digistuff:junctionbox", + recipe = { + {"homedecor:plastic_sheeting","digilines:wire_std_00000000","homedecor:plastic_sheeting",}, + {"digilines:wire_std_00000000","digilines:wire_std_00000000","digilines:wire_std_00000000",}, + {"homedecor:plastic_sheeting","digilines:wire_std_00000000","homedecor:plastic_sheeting",}, + } +}) diff --git a/textures/digistuff_junctionbox.png b/textures/digistuff_junctionbox.png new file mode 100644 index 0000000000000000000000000000000000000000..b878bc779be5d4de69cefb4bd11dbf99e874af3f GIT binary patch literal 4889 zcm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h@*h--qSVe*@v!E6wOsKRPE2@+0baHhNMLtUdYZH#(sst)4 zpi-ig3RT+_uv&{^uu7@HV2sdMU=3=MqgowlQBhWrN)Q%LEif6R3Yolrroch)HimT? zq`9=q47oH(xj5!gr3XX&vIN~PK+XO+a32D< zHKgyp7O({n`KNpZ?DkWpfS{oygVJ|Mt|7SwrNE%TL+%=qYfuUd3OwYlA5E^P{wHI~ z1^&_Vg6G~Hh;uo3W{z}c&*mhO=qH6wh-B58(O@#1H<>fS&qsztYvX2*_ud3kv8MFY i;)qk^ts2Aa36f!d4K4NAMlJ>m5>rNA`j)hLFZ~CDsrK^# literal 0 HcmV?d00001 diff --git a/textures/digistuff_light.png b/textures/digistuff_light.png new file mode 100644 index 0000000000000000000000000000000000000000..d51e29bc4362e332d418ca2ac626ceded0bc3856 GIT binary patch literal 181 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F3${@^GvDCf{D9B#o z>Fdh=h?9|9PwK`It}dXEWQl7;iF1B#Zfaf$gL6@8Vo7R>LV0FMhJw4NZ$Nk>pEyvF zzNd?0h{fsTKYxB5tY_n55N2*okdQdg?R_ literal 0 HcmV?d00001