From 97765470fc876e73ad6f2e6b547bf2fc7233a562 Mon Sep 17 00:00:00 2001 From: cheapie Date: Sat, 24 Nov 2018 15:56:29 -0600 Subject: Split components into their own files --- light.lua | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 light.lua (limited to 'light.lua') diff --git a/light.lua b/light.lua new file mode 100644 index 0000000..aeca08d --- /dev/null +++ b/light.lua @@ -0,0 +1,71 @@ +for i=0,14,1 do + local mult = 255 - ((14-i)*12) + 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", + paramtype2 = "facedir", + 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 = 2,y = 0,z = 0}, + {x = -2,y = 0,z = 0}, + {x = 0,y = 0,z = 2}, + {x = 0,y = 0,z = -2}, + {x = 0,y = 2,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 + local value = tonumber(msg) + if (not value) or value > 14 or value < 0 then return end + node.name = "digistuff:light_"..math.floor(value) + minetest.swap_node(pos,node) + end + }, + }, + }) +end + +minetest.register_craft({ + output = "digistuff:light_0", + recipe = { + {"digilines:wire_std_00000000","mesecons_lamp:lamp_off",}, + } +}) -- cgit v1.2.3