From ff236643afc815f42f41e2b7524dac385e25c817 Mon Sep 17 00:00:00 2001 From: cheapie Date: Sat, 1 Sep 2018 07:12:16 -0500 Subject: 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 0000000..b878bc7 Binary files /dev/null and b/textures/digistuff_junctionbox.png differ diff --git a/textures/digistuff_light.png b/textures/digistuff_light.png new file mode 100644 index 0000000..d51e29b Binary files /dev/null and b/textures/digistuff_light.png differ -- cgit v1.2.3