minetest.register_node("advtouchscreen:advtouchscreen", { description = "Advanced Digilines Touchscreen", groups = { cracky=3 }, on_construct = function(pos) minetest.get_meta(pos):set_string("formspec","field[channel;Channel;]") end, drawtype = "nodebox", tiles = { "advtouchscreen_sides.png", "advtouchscreen_sides.png", "advtouchscreen_sides.png", "advtouchscreen_sides.png", "advtouchscreen_sides.png", "advtouchscreen_front.png" }, paramtype = "light", paramtype2 = "facedir", node_box = { type = "fixed", fixed = { { -0.5, -0.5, 0.4, 0.5, 0.5, 0.5 } } }, _digistuff_channelcopier_fieldname = "channel", _digistuff_channelcopier_onset = function(pos) local meta = minetest.get_meta(pos) meta:set_int("init",1) meta:set_string("formspec","") end, on_receive_fields = function(pos,_,fields,player) local meta = minetest.get_meta(pos) local name = player:get_player_name() local protected = minetest.is_protected(pos,name) and not minetest.check_player_privs(name,"protection_bypass") if meta:get_int("init") == 0 then if fields.channel and fields.channel ~= "" then if protected then minetest.record_protection_violation(pos,name) minetest.chat_send_player(name,"You don't have access to set the channel on this screen.") return end meta:set_string("channel",fields.channel) meta:set_int("init",1) meta:set_string("formspec","") end else local locked = meta:get_int("locked") > 0 if locked and protected and not fields.quit then minetest.record_protection_violation(pos,name) minetest.chat_send_player(name,"This screen is locked.") return end fields.clicker = name digilines.receptor_send(pos,digilines.rules.default,meta:get_string("channel"),fields) end end, digiline = { receptor = {}, effector = { action = function(pos,_,channel,msg) local meta = minetest.get_meta(pos) if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end local lockcommands local unlockcommands --string.gsub() returns two values, the second one is how many times the replacement happened msg,lockcommands = string.gsub(msg,"lock%[1]","") msg,unlockcommands = string.gsub(msg,"lock%[0]","") if lockcommands > 0 then meta:set_int("locked",1) elseif unlockcommands > 0 then meta:set_int("locked",0) end meta:set_string("formspec",msg) end, }, }, }) minetest.register_alias_force("digistuff:advtouchscreen","advtouchscreen:advtouchscreen") minetest.register_craft({ output = "advtouchscreen:advtouchscreen", type = "shapeless", recipe = { "digistuff:touchscreen", "default:mese_crystal", }, })