local upbuttontex = "[combine:64x64".. ":0,0=elevatorparts_generic_bg.png".. ":22,24=elevatorparts_callbutton_bg.png".. ":24,35=elevatorparts_callbutton_up.png" minetest.register_node("elevatorparts:callbutton_up",{ description = "Up Call Button (unprogrammed)", groups = { dig_immediate = 2, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", upbuttontex, }, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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) meta:set_string("formspec","") local node = minetest.get_node(pos) node.name = "elevatorparts:callbutton_up_off" minetest.swap_node(pos,node) end end, _digistuff_channelcopier_fieldname = "channel", _digistuff_channelcopier_onset = function(pos,node) node.name = "elevatorparts:callbutton_up_off" minetest.swap_node(pos,node) minetest.get_meta(pos):set_string("formspec","") end, }) minetest.register_node("elevatorparts:callbutton_up_off",{ description = "Up Call Button (programmed, off state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", upbuttontex, }, drop = "elevatorparts:callbutton_up", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_punch = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"up_press") end, on_rightclick = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"up_press") end, digiline = { receptor = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_on" then node.name = "elevatorparts:callbutton_up_on" minetest.swap_node(pos,node) end end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:callbutton_up_on",{ description = "Up Call Button (programmed, on state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", upbuttontex..":33,36=elevatorparts_callbutton_light.png", }, drop = "elevatorparts:callbutton_up", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_punch = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"up_press") end, on_rightclick = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"up_press") end, digiline = { receptor = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_off" then node.name = "elevatorparts:callbutton_up_off" minetest.swap_node(pos,node) end end }, }, _digistuff_channelcopier_fieldname = "channel", }) local downbuttontex = "[combine:64x64".. ":0,0=elevatorparts_generic_bg.png".. ":22,24=elevatorparts_callbutton_bg.png".. ":24,35=elevatorparts_callbutton_down.png" minetest.register_node("elevatorparts:callbutton_down",{ description = "Down Call Button (unprogrammed)", groups = { dig_immediate = 2, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", downbuttontex, }, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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) meta:set_string("formspec","") local node = minetest.get_node(pos) node.name = "elevatorparts:callbutton_down_off" minetest.swap_node(pos,node) end end, _digistuff_channelcopier_fieldname = "channel", _digistuff_channelcopier_onset = function(pos,node) node.name = "elevatorparts:callbutton_down_off" minetest.swap_node(pos,node) minetest.get_meta(pos):set_string("formspec","") end, }) minetest.register_node("elevatorparts:callbutton_down_off",{ description = "Down Call Button (programmed, off state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", downbuttontex, }, drop = "elevatorparts:callbutton_down", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_punch = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"down_press") end, on_rightclick = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"down_press") end, digiline = { receptor = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "down_light_on" then node.name = "elevatorparts:callbutton_down_on" minetest.swap_node(pos,node) end end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:callbutton_down_on",{ description = "Down Call Button (programmed, on state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", downbuttontex..":33,36=elevatorparts_callbutton_light.png", }, drop = "elevatorparts:callbutton_down", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_punch = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"down_press") end, on_rightclick = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"down_press") end, digiline = { receptor = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "down_light_off" then node.name = "elevatorparts:callbutton_down_off" minetest.swap_node(pos,node) end end }, }, _digistuff_channelcopier_fieldname = "channel", }) local bothbuttontex = "[combine:64x64".. ":0,0=elevatorparts_generic_bg.png".. ":22,24=elevatorparts_callbutton_bg.png".. ":24,28=elevatorparts_callbutton_up.png".. ":24,43=elevatorparts_callbutton_down.png" minetest.register_node("elevatorparts:callbutton_both",{ description = "Up and Down Call Buttons (unprogrammed)", groups = { dig_immediate = 2, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", bothbuttontex, }, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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) meta:set_string("formspec","") meta:set_string("infotext","Left-click for up or right-click for down") local node = minetest.get_node(pos) node.name = "elevatorparts:callbutton_both_off" minetest.swap_node(pos,node) end end, _digistuff_channelcopier_fieldname = "channel", _digistuff_channelcopier_onset = function(pos,node) node.name = "elevatorparts:callbutton_both_off" minetest.swap_node(pos,node) minetest.get_meta(pos):set_string("formspec","") end, }) minetest.register_node("elevatorparts:callbutton_both_off",{ description = "Up and Down Call Buttons (programmed, both off state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", bothbuttontex, }, drop = "elevatorparts:callbutton_both", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_punch = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"up_press") end, on_rightclick = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"down_press") end, digiline = { receptor = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_on" then node.name = "elevatorparts:callbutton_both_upon" minetest.swap_node(pos,node) elseif msg == "down_light_on" then node.name = "elevatorparts:callbutton_both_downon" minetest.swap_node(pos,node) end end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:callbutton_both_upon",{ description = "Up and Down Call Buttons (programmed, up on, down off state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", bothbuttontex..":33,29=elevatorparts_callbutton_light.png", }, drop = "elevatorparts:callbutton_both", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_punch = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"up_press") end, on_rightclick = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"down_press") end, digiline = { receptor = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_off" then node.name = "elevatorparts:callbutton_both_off" minetest.swap_node(pos,node) elseif msg == "down_light_on" then node.name = "elevatorparts:callbutton_both_on" minetest.swap_node(pos,node) end end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:callbutton_both_downon",{ description = "Up and Down Call Buttons (programmed, up off, down on state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", bothbuttontex..":33,44=elevatorparts_callbutton_light.png", }, drop = "elevatorparts:callbutton_both", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_punch = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"up_press") end, on_rightclick = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"down_press") end, digiline = { receptor = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_on" then node.name = "elevatorparts:callbutton_both_on" minetest.swap_node(pos,node) elseif msg == "down_light_off" then node.name = "elevatorparts:callbutton_both_off" minetest.swap_node(pos,node) end end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:callbutton_both_on",{ description = "Up and Down Call Buttons (programmed, both on state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", bothbuttontex..":33,29=elevatorparts_callbutton_light.png:33,44=elevatorparts_callbutton_light.png", }, drop = "elevatorparts:callbutton_both", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, {-0.16, -0.37, 0.45, 0.17, 0.13, 0.48}, }, }, on_punch = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"up_press") end, on_rightclick = function(pos) digilines.receptor_send(pos,digilines.rules.default,minetest.get_meta(pos):get_string("channel"),"down_press") end, digiline = { receptor = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_off" then node.name = "elevatorparts:callbutton_both_downon" minetest.swap_node(pos,node) elseif msg == "down_light_off" then node.name = "elevatorparts:callbutton_both_upon" minetest.swap_node(pos,node) end end }, }, _digistuff_channelcopier_fieldname = "channel", }) local chars = { ["0"] = "elevatorparts_pi_0.png", ["1"] = "elevatorparts_pi_1.png", ["2"] = "elevatorparts_pi_2.png", ["3"] = "elevatorparts_pi_3.png", ["4"] = "elevatorparts_pi_4.png", ["5"] = "elevatorparts_pi_5.png", ["6"] = "elevatorparts_pi_6.png", ["7"] = "elevatorparts_pi_7.png", ["8"] = "elevatorparts_pi_8.png", ["9"] = "elevatorparts_pi_9.png", ["a"] = "elevatorparts_pi_a.png", ["b"] = "elevatorparts_pi_b.png", ["c"] = "elevatorparts_pi_c.png", ["d"] = "elevatorparts_pi_d.png", ["e"] = "elevatorparts_pi_e.png", ["f"] = "elevatorparts_pi_f.png", ["g"] = "elevatorparts_pi_9.png", ["h"] = "elevatorparts_pi_h.png", ["i"] = "elevatorparts_pi_1.png", ["j"] = "elevatorparts_pi_j.png", ["l"] = "elevatorparts_pi_l.png", ["n"] = "elevatorparts_pi_n.png", ["o"] = "elevatorparts_pi_0.png", ["p"] = "elevatorparts_pi_p.png", ["r"] = "elevatorparts_pi_r.png", ["s"] = "elevatorparts_pi_5.png", ["t"] = "elevatorparts_pi_t.png", ["u"] = "elevatorparts_pi_u.png", ["y"] = "elevatorparts_pi_y.png", ["z"] = "elevatorparts_pi_2.png", ["-"] = "elevatorparts_pi_dash.png", } minetest.register_entity("elevatorparts:pi_entity",{ initial_properties = { visual = "upright_sprite", physical = false, collisionbox = {0,0,0,0,0,0,}, textures = {"elevatorparts_transparent.png",}, }, }) local function removeEntity(pos) local entitiesNearby = minetest.get_objects_inside_radius(pos,0.5) for _,i in pairs(entitiesNearby) do if i:get_luaentity() and i:get_luaentity().name == "elevatorparts:pi_entity" then i:remove() end end end local function generateTexture(text,uparrow,downarrow) local out = "[combine:64x64:0,0=elevatorparts_transparent.png" local pos = 0 for i=1,string.len(text),1 do local char = string.sub(text,i,i) if char ~= " " then out = out..string.format(":%d,%d=%s",pos*12+22,7,chars[char] or chars["-"]) end pos = pos+1 end if uparrow then out = out..":6,7=elevatorparts_pi_arrow_up.png" elseif downarrow then out = out..":6,7=elevatorparts_pi_arrow_down.png" end return out end local function updateDisplay(pos) removeEntity(pos) local meta = minetest.get_meta(pos) local text = meta:get_string("text") local entity = minetest.add_entity(pos,"elevatorparts:pi_entity") local fdir = minetest.facedir_to_dir(minetest.get_node(pos).param2) local uparrow = meta:get_int("uparrow") > 0 local downarrow = meta:get_int("downarrow") > 0 local flash_fs = meta:get_int("flash_fs") > 0 local flash_is = meta:get_int("flash_is") > 0 local flashtimer = meta:get_int("flashtimer") > 0 local etex = generateTexture(text,uparrow,downarrow) if flash_fs then if flashtimer then etex = generateTexture(" fs",uparrow,downarrow) end entity:set_properties({_flash_fs = true,_flash_is = false,}) elseif flash_is then if flashtimer then etex = generateTexture(" n",uparrow,downarrow) end entity:set_properties({_flash_fs = false,_flash_is = true,}) else entity:set_properties({_flash_fs = false,_flash_is = false,}) end entity:set_properties({textures={etex}}) entity:set_yaw((fdir.x ~= 0) and math.pi/2 or 0) entity:set_pos(vector.add(pos,vector.multiply(fdir,0.45))) end local pi_ignore = { up_light_on = true, up_light_off = true, down_light_on = true, down_light_off = true, up_press = true, down_press = true, arrow_up = true, arrow_down = true, arrow_off = true, flash_is = true, flash_fs = true, flash_off = true, } minetest.register_node("elevatorparts:pilantern_up_off",{ description = "PI + Up Lantern Combo", groups = { dig_immediate = 2, elevatorparts_pi_abm = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "[combine:64x64:0,0=elevatorparts_pilantern_bg.png:25,37=elevatorparts_lantern_up_off.png", }, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, }, }, on_destruct = removeEntity, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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 = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_on" then node.name = "elevatorparts:pilantern_up_on" minetest.swap_node(pos,node) elseif msg == "arrow_up" then meta:set_int("uparrow",1) meta:set_int("downarrow",0) elseif msg == "arrow_down" then meta:set_int("uparrow",0) meta:set_int("downarrow",1) elseif msg == "arrow_off" then meta:set_int("uparrow",0) meta:set_int("downarrow",0) elseif msg == "flash_is" then meta:set_int("flash_is",1) meta:set_int("flash_fs",0) elseif msg == "flash_fs" then meta:set_int("flash_is",0) meta:set_int("flash_fs",1) elseif msg == "flash_off" then meta:set_int("flash_is",0) meta:set_int("flash_fs",0) elseif not pi_ignore[msg] then meta:set_string("text",string.sub(" "..msg,-3,-1)) end updateDisplay(pos) end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:pilantern_up_on",{ description = "PI + Up Lantern Combo (on state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, elevatorparts_pi_abm = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "[combine:64x64:0,0=elevatorparts_pilantern_bg.png:25,37=elevatorparts_lantern_up_on.png", }, drop = "elevatorparts:pilantern_up_off", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, }, }, on_destruct = removeEntity, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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 = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_off" then node.name = "elevatorparts:pilantern_up_off" minetest.swap_node(pos,node) elseif msg == "arrow_up" then meta:set_int("uparrow",1) meta:set_int("downarrow",0) elseif msg == "arrow_down" then meta:set_int("uparrow",0) meta:set_int("downarrow",1) elseif msg == "arrow_off" then meta:set_int("uparrow",0) meta:set_int("downarrow",0) elseif msg == "flash_is" then meta:set_int("flash_is",1) meta:set_int("flash_fs",0) elseif msg == "flash_fs" then meta:set_int("flash_is",0) meta:set_int("flash_fs",1) elseif msg == "flash_off" then meta:set_int("flash_is",0) meta:set_int("flash_fs",0) elseif not pi_ignore[msg] then meta:set_string("text",string.sub(" "..msg,-3,-1)) end updateDisplay(pos) end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:pilantern_down_off",{ description = "PI + Down Lantern Combo", groups = { dig_immediate = 2, elevatorparts_pi_abm = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "[combine:64x64:0,0=elevatorparts_pilantern_bg.png:25,37=elevatorparts_lantern_down_off.png", }, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, }, }, on_destruct = removeEntity, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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 = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "down_light_on" then node.name = "elevatorparts:pilantern_down_on" minetest.swap_node(pos,node) elseif msg == "arrow_up" then meta:set_int("uparrow",1) meta:set_int("downarrow",0) elseif msg == "arrow_down" then meta:set_int("uparrow",0) meta:set_int("downarrow",1) elseif msg == "arrow_off" then meta:set_int("uparrow",0) meta:set_int("downarrow",0) elseif msg == "flash_is" then meta:set_int("flash_is",1) meta:set_int("flash_fs",0) elseif msg == "flash_fs" then meta:set_int("flash_is",0) meta:set_int("flash_fs",1) elseif msg == "flash_off" then meta:set_int("flash_is",0) meta:set_int("flash_fs",0) elseif not pi_ignore[msg] then meta:set_string("text",string.sub(" "..msg,-3,-1)) end updateDisplay(pos) end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:pilantern_down_on",{ description = "PI + Down Lantern Combo (on state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, elevatorparts_pi_abm = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "[combine:64x64:0,0=elevatorparts_pilantern_bg.png:25,37=elevatorparts_lantern_down_on.png", }, drop = "elevatorparts:pilantern_down_off", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, }, }, on_destruct = removeEntity, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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 = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "down_light_off" then node.name = "elevatorparts:pilantern_down_off" minetest.swap_node(pos,node) elseif msg == "arrow_up" then meta:set_int("uparrow",1) meta:set_int("downarrow",0) elseif msg == "arrow_down" then meta:set_int("uparrow",0) meta:set_int("downarrow",1) elseif msg == "arrow_off" then meta:set_int("uparrow",0) meta:set_int("downarrow",0) elseif msg == "flash_is" then meta:set_int("flash_is",1) meta:set_int("flash_fs",0) elseif msg == "flash_fs" then meta:set_int("flash_is",0) meta:set_int("flash_fs",1) elseif msg == "flash_off" then meta:set_int("flash_is",0) meta:set_int("flash_fs",0) elseif not pi_ignore[msg] then meta:set_string("text",string.sub(" "..msg,-3,-1)) end updateDisplay(pos) end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:pilantern_updown_off",{ description = "PI + Up and Down Lantern Combo", groups = { dig_immediate = 2, elevatorparts_pi_abm = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "[combine:64x64:0,0=elevatorparts_pilantern_bg.png:10,37=elevatorparts_lantern_up_off.png:39,37=elevatorparts_lantern_down_off.png", }, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, }, }, on_destruct = removeEntity, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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 = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_on" then node.name = "elevatorparts:pilantern_updown_upon" minetest.swap_node(pos,node) elseif msg == "down_light_on" then node.name = "elevatorparts:pilantern_updown_downon" minetest.swap_node(pos,node) elseif msg == "arrow_up" then meta:set_int("uparrow",1) meta:set_int("downarrow",0) elseif msg == "arrow_down" then meta:set_int("uparrow",0) meta:set_int("downarrow",1) elseif msg == "arrow_off" then meta:set_int("uparrow",0) meta:set_int("downarrow",0) elseif msg == "flash_is" then meta:set_int("flash_is",1) meta:set_int("flash_fs",0) elseif msg == "flash_fs" then meta:set_int("flash_is",0) meta:set_int("flash_fs",1) elseif msg == "flash_off" then meta:set_int("flash_is",0) meta:set_int("flash_fs",0) elseif not pi_ignore[msg] then meta:set_string("text",string.sub(" "..msg,-3,-1)) end updateDisplay(pos) end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:pilantern_updown_upon",{ description = "PI + Up and Down Lantern Combo (up on, down off state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, elevatorparts_pi_abm = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "[combine:64x64:0,0=elevatorparts_pilantern_bg.png:10,37=elevatorparts_lantern_up_on.png:39,37=elevatorparts_lantern_down_off.png", }, drop = "elevatorparts:pilantern_updown_off", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, }, }, on_destruct = removeEntity, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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 = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_off" then node.name = "elevatorparts:pilantern_updown_off" minetest.swap_node(pos,node) elseif msg == "down_light_on" then node.name = "elevatorparts:pilantern_updown_bothon" minetest.swap_node(pos,node) elseif msg == "arrow_up" then meta:set_int("uparrow",1) meta:set_int("downarrow",0) elseif msg == "arrow_down" then meta:set_int("uparrow",0) meta:set_int("downarrow",1) elseif msg == "arrow_off" then meta:set_int("uparrow",0) meta:set_int("downarrow",0) elseif msg == "flash_is" then meta:set_int("flash_is",1) meta:set_int("flash_fs",0) elseif msg == "flash_fs" then meta:set_int("flash_is",0) meta:set_int("flash_fs",1) elseif msg == "flash_off" then meta:set_int("flash_is",0) meta:set_int("flash_fs",0) elseif not pi_ignore[msg] then meta:set_string("text",string.sub(" "..msg,-3,-1)) end updateDisplay(pos) end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:pilantern_updown_downon",{ description = "PI + Up and Down Lantern Combo (up off, down on state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, elevatorparts_pi_abm = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "[combine:64x64:0,0=elevatorparts_pilantern_bg.png:10,37=elevatorparts_lantern_up_off.png:39,37=elevatorparts_lantern_down_on.png", }, drop = "elevatorparts:pilantern_updown_off", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, }, }, on_destruct = removeEntity, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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 = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_on" then node.name = "elevatorparts:pilantern_updown_bothon" minetest.swap_node(pos,node) elseif msg == "down_light_off" then node.name = "elevatorparts:pilantern_updown_off" minetest.swap_node(pos,node) elseif msg == "arrow_up" then meta:set_int("uparrow",1) meta:set_int("downarrow",0) elseif msg == "arrow_down" then meta:set_int("uparrow",0) meta:set_int("downarrow",1) elseif msg == "arrow_off" then meta:set_int("uparrow",0) meta:set_int("downarrow",0) elseif msg == "flash_is" then meta:set_int("flash_is",1) meta:set_int("flash_fs",0) elseif msg == "flash_fs" then meta:set_int("flash_is",0) meta:set_int("flash_fs",1) elseif msg == "flash_off" then meta:set_int("flash_is",0) meta:set_int("flash_fs",0) elseif not pi_ignore[msg] then meta:set_string("text",string.sub(" "..msg,-3,-1)) end updateDisplay(pos) end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_node("elevatorparts:pilantern_updown_bothon",{ description = "PI + Up and Down Lantern Combo (both on state - you hacker you!)", groups = { dig_immediate = 2, not_in_creative_inventory = 1, elevatorparts_pi_abm = 1, }, tiles = { "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "elevatorparts_generic_bg.png", "[combine:64x64:0,0=elevatorparts_pilantern_bg.png:10,37=elevatorparts_lantern_up_on.png:39,37=elevatorparts_lantern_down_on.png", }, drop = "elevatorparts:pilantern_updown_off", paramtype = "light", paramtype2 = "facedir", is_ground_content = false, sunlight_propagates = true, drawtype = "nodebox", node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.48, 0.5, 0.5, 0.5 }, }, }, on_destruct = removeEntity, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec","field[channel;Channel;${channel}") end, on_receive_fields = function(pos,_,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 = {}, effector = { action = function(pos,node,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end msg = string.lower(msg) if msg == "up_light_off" then node.name = "elevatorparts:pilantern_updown_downon" minetest.swap_node(pos,node) elseif msg == "down_light_off" then node.name = "elevatorparts:pilantern_updown_upon" minetest.swap_node(pos,node) elseif msg == "arrow_up" then meta:set_int("uparrow",1) meta:set_int("downarrow",0) elseif msg == "arrow_down" then meta:set_int("uparrow",0) meta:set_int("downarrow",1) elseif msg == "arrow_off" then meta:set_int("uparrow",0) meta:set_int("downarrow",0) elseif msg == "flash_is" then meta:set_int("flash_is",1) meta:set_int("flash_fs",0) elseif msg == "flash_fs" then meta:set_int("flash_is",0) meta:set_int("flash_fs",1) elseif msg == "flash_off" then meta:set_int("flash_is",0) meta:set_int("flash_fs",0) elseif not pi_ignore[msg] then meta:set_string("text",string.sub(" "..msg,-3,-1)) end updateDisplay(pos) end }, }, _digistuff_channelcopier_fieldname = "channel", }) minetest.register_abm({ label = "Respawn / Flash PI displays", nodenames = {"group:elevatorparts_pi_abm"}, interval = 1, chance = 1, action = function(pos) local meta = minetest.get_meta(pos) local flashtimer = meta:get_int("flashtimer") > 0 meta:set_int("flashtimer",flashtimer and 0 or 1) updateDisplay(pos) end, }) minetest.register_craft({ output = "elevatorparts:callbutton_up", recipe = { {"basic_materials:plastic_sheet","mesecons_button:button_off","basic_materials:plastic_sheet"}, {"mesecons_luacontroller:luacontroller0000","mesecons_lightstone:lightstone_blue_off","basic_materials:plastic_sheet"}, {"basic_materials:plastic_sheet","","basic_materials:plastic_sheet"}, }, }) minetest.register_craft({ output = "elevatorparts:callbutton_down", recipe = { {"basic_materials:plastic_sheet","","basic_materials:plastic_sheet"}, {"mesecons_luacontroller:luacontroller0000","mesecons_lightstone:lightstone_blue_off","basic_materials:plastic_sheet"}, {"basic_materials:plastic_sheet","mesecons_button:button_off","basic_materials:plastic_sheet"}, }, }) minetest.register_craft({ output = "elevatorparts:callbutton_both", recipe = { {"basic_materials:plastic_sheet","mesecons_button:button_off","basic_materials:plastic_sheet"}, {"mesecons_luacontroller:luacontroller0000","mesecons_lightstone:lightstone_blue_off","basic_materials:plastic_sheet"}, {"basic_materials:plastic_sheet","mesecons_button:button_off","basic_materials:plastic_sheet"}, }, }) minetest.register_craft({ output = "elevatorparts:pilantern_up_off", recipe = { {"basic_materials:plastic_sheet","basic_materials:plastic_sheet","basic_materials:plastic_sheet"}, {"mesecons_luacontroller:luacontroller0000","digilines:lcd","basic_materials:plastic_sheet"}, {"basic_materials:plastic_sheet","mesecons_lightstone:lightstone_green_off","basic_materials:plastic_sheet"}, }, }) minetest.register_craft({ output = "elevatorparts:pilantern_down_off", recipe = { {"basic_materials:plastic_sheet","basic_materials:plastic_sheet","basic_materials:plastic_sheet"}, {"mesecons_luacontroller:luacontroller0000","digilines:lcd","basic_materials:plastic_sheet"}, {"basic_materials:plastic_sheet","mesecons_lightstone:lightstone_red_off","basic_materials:plastic_sheet"}, }, }) minetest.register_craft({ output = "elevatorparts:pilantern_updown_off", recipe = { {"basic_materials:plastic_sheet","basic_materials:plastic_sheet","basic_materials:plastic_sheet"}, {"mesecons_luacontroller:luacontroller0000","digilines:lcd","basic_materials:plastic_sheet"}, {"mesecons_lightstone:lightstone_green_off","basic_materials:plastic_sheet","mesecons_lightstone:lightstone_red_off"}, }, }) if minetest.global_exists("digistuff") and type(digistuff.register_nb_sound) == "function" then for _,filename in ipairs(minetest.get_dir_list(minetest.get_modpath("elevatorparts").."/sounds",false)) do local name = string.sub(filename,1,-5) digistuff.register_nb_sound(name,name) end end