Add files via upload
125
craft.lua
Normal file
@ -0,0 +1,125 @@
|
||||
minetest.register_craft({
|
||||
output = "mesetec:nodeswitch",
|
||||
recipe = {{"","mesecons:wire_00000000_off",""},
|
||||
{"mesecons_materials:silicon","mesecons_lamp:lamp_off","mesecons_materials:silicon"},
|
||||
{"","default:mese_crystal",""},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:objdec",
|
||||
recipe = {{"mesecons_materials:silicon","mesecons_solarpanel:solar_panel_off","mesecons_materials:silicon"}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:light",
|
||||
recipe = {{"mesecons_materials:silicon","mesecons_solarpanel:solar_panel_off","mesecons_materials:silicon"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:delayer",
|
||||
recipe = {{"mesecons_delayer:delayer_off_1","default:copper_ingot","mesecons_delayer:delayer_off_1"},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:oxygen 3",
|
||||
recipe = {{"","mesecons:wire_00000000_off",""},
|
||||
{"default:sand","mesecons_lamp:lamp_off","default:sand"},
|
||||
{"","default:torch",""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:dmg 3",
|
||||
recipe = {{"","mesecons:wire_00000000_off",""},
|
||||
{"default:sand","mesecons_lamp:lamp_off","default:sand"},
|
||||
{"","default:mese_crystal",""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:ladder 3",
|
||||
recipe = {{"","mesecons:wire_00000000_off",""},
|
||||
{"default:sand","mesecons_lamp:lamp_off","default:sand"},
|
||||
{"","default:ladder_wood",""},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:keycard",
|
||||
recipe = {{"mesecons_materials:silicon","mesecons:wire_00000000_off","mesecons_materials:silicon"},
|
||||
{"mesecons_materials:silicon","mesecons_lamp:lamp_off","mesecons_materials:silicon"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:codelock",
|
||||
recipe = {{"default:steel_ingot","mesecons:wire_00000000_off","default:steel_ingot"},
|
||||
{"default:steel_ingot","mesecons_luacontroller:luacontroller0000","default:steel_ingot"},
|
||||
{"default:steel_ingot","mesecons_lamp:lamp_off","default:steel_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:controller",
|
||||
recipe = {{"","mesecons:wire_00000000_off",""},
|
||||
{"default:steel_ingot","mesecons_walllever:wall_lever_off","default:steel_ingot"},
|
||||
{"","default:stick",""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:hacktool",
|
||||
recipe = {{"mesecons:wire_00000000_off","","mesecons:wire_00000000_off"},
|
||||
{"default:steel_ingot","default:mese_crystal","default:steel_ingot"},
|
||||
{"","default:stick",""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:objdec",
|
||||
recipe = {{"","mesecons:wire_00000000_off",""},
|
||||
{"","mesecons_detector:object_detector_off",""},
|
||||
{"","mesecons_luacontroller:luacontroller0000",""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:mtptarget",
|
||||
recipe = {{"default:steel_ingot","mesecons:wire_00000000_off","default:steel_ingot"},
|
||||
{"default:steel_ingot","default:mese_crystal","default:steel_ingot"},
|
||||
{"default:steel_ingot","default:steel_ingot","default:steel_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:mtp",
|
||||
recipe = {{"default:steel_ingot","mesecons:wire_00000000_off","default:steel_ingot"},
|
||||
{"default:mese_crystal","mesecons_luacontroller:luacontroller0000","default:mese_crystal"},
|
||||
{"default:steel_ingot","default:steel_ingot","default:steel_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:ptp",
|
||||
recipe = {{"default:steel_ingot","mesecons:wire_00000000_off","default:steel_ingot"},
|
||||
{"default:mese_crystal_fragment","mesecons_detector:object_detector_off","default:mese_crystal_fragment"},
|
||||
{"default:steel_ingot","default:steel_ingot","default:steel_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesetec:ptptarget",
|
||||
recipe = {{"default:steel_ingot","mesecons:wire_00000000_off","default:steel_ingot"},
|
||||
{"default:mese_crystal_fragment","mesecons_luacontroller:luacontroller0000","default:mese_crystal_fragment"},
|
||||
{"default:steel_ingot","default:steel_ingot","default:steel_ingot"},
|
||||
}
|
||||
})
|
2
depends.txt
Normal file
@ -0,0 +1,2 @@
|
||||
default
|
||||
mesecons
|
1
description.txt
Normal file
@ -0,0 +1 @@
|
||||
Extra and usefull mesecons stuff
|
204
init.lua
Normal file
@ -0,0 +1,204 @@
|
||||
mesetec={maxlight=default.LIGHT_MAX or 15, player_teleport={},mtcuser={},mtpuser={},rules={{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=0,y=0,z=1},{x=0,y=0,z=-1}}
|
||||
|
||||
|
||||
|
||||
,mtp_distance=30, --Mese teleport distance
|
||||
}
|
||||
dofile(minetest.get_modpath("mesetec") .. "/tools.lua")
|
||||
dofile(minetest.get_modpath("mesetec") .. "/teleob.lua")
|
||||
dofile(minetest.get_modpath("mesetec") .. "/misc.lua")
|
||||
|
||||
dofile(minetest.get_modpath("mesetec") .. "/craft.lua")
|
||||
|
||||
mesetec.distance=function(p,o)
|
||||
return math.sqrt((p.x-o.x)*(p.x-o.x) + (p.y-o.y)*(p.y-o.y)+(p.z-o.z)*(p.z-o.z))
|
||||
end
|
||||
|
||||
mesetec.strpos=function(str,spl)
|
||||
if spl then
|
||||
local c=","
|
||||
if string.find(str," ") then c=" " end
|
||||
local s=str.split(str,c)
|
||||
if s[3]==nil then
|
||||
return nil
|
||||
else
|
||||
return {x=tonumber(s[1]),y=tonumber(s[2]),z=tonumber(s[3])}
|
||||
end
|
||||
else if str.x and str.y and str.z then
|
||||
return str.x .."," .. str.y .."," .. str.z
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
mesetec.form1=function(pos,player,type)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local data=meta:get_string("data")
|
||||
mesetec.mtpuser[player:get_player_name()]=pos
|
||||
local gui=""
|
||||
local label=""
|
||||
local field=""
|
||||
local form=""
|
||||
if type=="pos" then
|
||||
if data=="" then
|
||||
local ppos=player:get_pos()
|
||||
ppos={x=math.floor(ppos.x+0.5),y=math.floor(ppos.y+0.5),z=math.floor(ppos.z+0.5)}
|
||||
data=mesetec.strpos(ppos,false)
|
||||
end
|
||||
label="Position of mese teleport target"
|
||||
field=data
|
||||
form="form1"
|
||||
elseif type=="obj" then
|
||||
label="Entity name, (like mobs:sheep)"
|
||||
field=data
|
||||
form="form2"
|
||||
elseif type=="num" then
|
||||
if data=="" then
|
||||
data=minetest.get_node_light(pos)
|
||||
if not data then data=0 end
|
||||
else
|
||||
data=meta:get_int("light")
|
||||
end
|
||||
label="Light (from 0 to " .. mesetec.maxlight .. ")"
|
||||
field=data
|
||||
form="form3"
|
||||
end
|
||||
gui=""
|
||||
.."size[3.5,0.2]"
|
||||
.."tooltip[data;".. label .."]"
|
||||
.."field[0,0;3,1;data;;" .. field .."]"
|
||||
.."button_exit[2.5,-0.3;1.3,1;save;Save]"
|
||||
minetest.after((0.1), function(gui)
|
||||
return minetest.show_formspec(player:get_player_name(), "mesetec." .. form,gui)
|
||||
end, gui)
|
||||
end
|
||||
minetest.register_on_player_receive_fields(function(player, form, pressed)
|
||||
if form=="mesetec.code" then
|
||||
local name=player:get_player_name()
|
||||
local pos=mesetec.mtpuser[name]
|
||||
mesetec.mtpuser[name]=nil
|
||||
if pressed.data==nil then
|
||||
mesetec.mtcuser[name]=nil
|
||||
return
|
||||
end
|
||||
local n=0
|
||||
if pressed.b1 then
|
||||
n=1
|
||||
elseif pressed.b2 then
|
||||
n=2
|
||||
elseif pressed.b3 then
|
||||
n=3
|
||||
elseif pressed.b4 then
|
||||
n=4
|
||||
elseif pressed.b5 then
|
||||
n=5
|
||||
elseif pressed.b6 then
|
||||
n=6
|
||||
elseif pressed.b7 then
|
||||
n=7
|
||||
elseif pressed.b8 then
|
||||
n=8
|
||||
elseif pressed.b9 then
|
||||
n=9
|
||||
end
|
||||
if pressed.save then
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_string("data",pressed.data)
|
||||
minetest.chat_send_player(name, "Code set!")
|
||||
mesetec.mtcuser[name]=nil
|
||||
return
|
||||
elseif pressed.ok then
|
||||
local meta=minetest.get_meta(pos)
|
||||
if pressed.data==meta:get_string("data") then
|
||||
local node=minetest.get_node(pos)
|
||||
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||
minetest.after(1, function(pos,node)
|
||||
mesecon.receptor_off(pos, mesecon.rules.buttonlike_get(node))
|
||||
end, pos,node)
|
||||
mesetec.mtcuser[name]=nil
|
||||
return
|
||||
elseif meta:get_string("owner")==name then
|
||||
n=""
|
||||
pressed.data=meta:get_string("data")
|
||||
else
|
||||
mesetec.mtcuser[name]=""
|
||||
pressed.data=""
|
||||
n=""
|
||||
end
|
||||
end
|
||||
mesetec.mtcuser[name]=pressed.data .. n
|
||||
minetest.after(0.1, function(pos,player)
|
||||
mesetec.form2(pos,player)
|
||||
end, pos,player)
|
||||
return
|
||||
end
|
||||
if form=="mesetec.form1" then
|
||||
if pressed.save then
|
||||
local name=player:get_player_name()
|
||||
local pos=mesetec.mtpuser[name]
|
||||
mesetec.mtpuser[name]=nil
|
||||
if minetest.is_protected(pos, name)==false then
|
||||
local meta=minetest.get_meta(pos)
|
||||
local po1=pressed.data
|
||||
local po=mesetec.strpos(po1,true)
|
||||
if po and po.x and po.y and po.z and minetest.get_node(po) then
|
||||
if mesetec.distance(pos,po)>mesetec.mtp_distance then
|
||||
minetest.chat_send_player(name, "Error: too faraway (max: " .. mesetec.mtp_distance ..", current: " .. (math.floor(mesetec.distance(pos,po)+0.5)) .. ")")
|
||||
else
|
||||
meta:set_string("data",po1)
|
||||
minetest.chat_send_player(name, "Target set!")
|
||||
|
||||
if minetest.get_node(po).name~="mesetec:mtptarget" then
|
||||
minetest.chat_send_player(name, "Place a mese teleport target on the position")
|
||||
end
|
||||
end
|
||||
return true
|
||||
else
|
||||
minetest.chat_send_player(name, "Error: void position")
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
|
||||
elseif form=="mesetec.form2" then
|
||||
if pressed.save then
|
||||
local name=player:get_player_name()
|
||||
local pos=mesetec.mtpuser[name]
|
||||
mesetec.mtpuser[name]=nil
|
||||
if minetest.is_protected(pos, name)==false then
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_string("data",pressed.data)
|
||||
minetest.chat_send_player(name, "Target set!")
|
||||
if pressed.data~="" and not minetest.registered_entities[pressed.data] then
|
||||
minetest.chat_send_player(name, "The entity does not exist")
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
return true
|
||||
elseif form=="mesetec.form3" then
|
||||
if pressed.save then
|
||||
local name=player:get_player_name()
|
||||
local pos=mesetec.mtpuser[name]
|
||||
mesetec.mtpuser[name]=nil
|
||||
if minetest.is_protected(pos, name)==false then
|
||||
local meta=minetest.get_meta(pos)
|
||||
local l=tonumber(pressed.data)
|
||||
if not l or l=="" or l<0 then
|
||||
l=0
|
||||
elseif l>mesetec.maxlight then
|
||||
l=mesetec.maxlight
|
||||
end
|
||||
meta:set_int("light",l)
|
||||
meta:set_string("data",1)
|
||||
minetest.get_node_timer(pos):start(5)
|
||||
minetest.chat_send_player(name, "Time set!")
|
||||
return true
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
end)
|
278
misc.lua
Normal file
@ -0,0 +1,278 @@
|
||||
mesetec.form2=function(pos,player,try)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local name=player:get_player_name()
|
||||
local owner=meta:get_string("owner")==name
|
||||
local data=meta:get_string("data")
|
||||
mesetec.mtpuser[player:get_player_name()]=pos
|
||||
local gui=""
|
||||
gui=""
|
||||
.."size[3,5]"
|
||||
.."tooltip[data;Enter code]"
|
||||
.."button[0,1;1,1;b1;1]"
|
||||
.."button[1,1;1,1;b2;2]"
|
||||
.."button[2,1;1,1;b3;3]"
|
||||
.."button[0,2;1,1;b4;4]"
|
||||
.."button[1,2;1,1;b5;5]"
|
||||
.."button[2,2;1,1;b6;6]"
|
||||
.."button[0,3;1,1;b7;7]"
|
||||
.."button[1,3;1,1;b8;8]"
|
||||
.."button[2,3;1,1;b9;9]"
|
||||
.."button[1,4;1,1;b0;0]"
|
||||
if owner then
|
||||
if not mesetec.mtcuser[name] then
|
||||
mesetec.mtcuser[name]=data
|
||||
end
|
||||
gui=gui.."button_exit[2,4;1,1;ok;OK]"
|
||||
gui=gui.."button_exit[0,4;1,1;save;Save]"
|
||||
gui=gui.."field[0.3,0;3,1;data;;" .. mesetec.mtcuser[name] .."]"
|
||||
else
|
||||
if not mesetec.mtcuser[name] then
|
||||
mesetec.mtcuser[name]=""
|
||||
end
|
||||
gui=gui.."button_exit[2,4;1,1;ok;OK]"
|
||||
gui=gui.."field[0.3,0;3,1;data;;" .. mesetec.mtcuser[name] .."]"
|
||||
mesetec.mtcuser[name]=nil
|
||||
end
|
||||
minetest.after(0.1, function(gui)
|
||||
return minetest.show_formspec(player:get_player_name(), "mesetec.code",gui)
|
||||
end, gui)
|
||||
end
|
||||
|
||||
|
||||
minetest.register_node("mesetec:codelock", {
|
||||
description = "Codelock panel",
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
mesetec.form2(pos,player)
|
||||
end,
|
||||
tiles = {"default_steel_block.png","default_steel_block.png","default_steel_block.png","default_steel_block.png","default_steel_block.png","mesetec_code.png"},
|
||||
groups = {mesecon_needs_receiver = 1,snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
mesecons = {receptor = {
|
||||
rules = mesecon.rules.buttonlike_get,
|
||||
state = mesecon.state.off
|
||||
}},
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_string("owner",placer:get_player_name())
|
||||
end,
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.1875, -0.4375, 0.375, 0.1875, 0.0625, 0.5},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_node("mesetec:dmg", {
|
||||
description = "Mese damage block",
|
||||
tiles = {"mesetec_trap.png^[colorize:#f9570001"},
|
||||
alpha=1,
|
||||
inventory_image = "default_lava.png^mesetec_trap2.png",
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
drawtype="glasslike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.off,
|
||||
onstate = "mesetec:dmg2",
|
||||
rules = mesetec.rules
|
||||
}},
|
||||
})
|
||||
minetest.register_node("mesetec:dmg2", {
|
||||
description = "Mese damage block",
|
||||
tiles = {"mesetec_trap.png"},
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=1},
|
||||
is_ground_content = false,
|
||||
drawtype="glasslike",
|
||||
alpha=0,
|
||||
pointable = false,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
damage_per_second = 2,
|
||||
walkable = false,
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.on,
|
||||
offstate = "mesetec:dmg",
|
||||
rules = mesetec.rules
|
||||
}},
|
||||
})
|
||||
|
||||
minetest.register_node("mesetec:oxygen", {
|
||||
description = "Mese oxygen block",
|
||||
tiles = {"mesetec_trap.png^[colorize:#00a5a201"},
|
||||
alpha=1,
|
||||
inventory_image = "default_river_water.png^mesetec_trap2.png",
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
drawtype="glasslike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.off,
|
||||
onstate = "mesetec:oxygen2",
|
||||
rules = mesetec.rules
|
||||
}},
|
||||
})
|
||||
minetest.register_node("mesetec:oxygen2", {
|
||||
description = "Mese oxygen block",
|
||||
tiles = {"mesetec_trap.png"},
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=1},
|
||||
is_ground_content = false,
|
||||
drawtype="glasslike",
|
||||
alpha=1,
|
||||
pointable = false,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drowning = 1,
|
||||
walkable = false,
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.on,
|
||||
offstate = "mesetec:oxygen",
|
||||
rules = mesetec.rules
|
||||
}},
|
||||
})
|
||||
|
||||
minetest.register_node("mesetec:ladder", {
|
||||
description = "Mese ladder block",
|
||||
tiles = {"mesetec_trap.png^[colorize:#87878701"},
|
||||
alpha=1,
|
||||
inventory_image = "default_ladder_wood.png^mesetec_trap2.png",
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
drawtype="glasslike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.off,
|
||||
onstate = "mesetec:ladder2",
|
||||
rules = mesetec.rules
|
||||
}},
|
||||
})
|
||||
minetest.register_node("mesetec:ladder2", {
|
||||
description = "Mese ladder block",
|
||||
tiles = {"mesetec_trap.png"},
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=1},
|
||||
is_ground_content = false,
|
||||
drawtype="glasslike",
|
||||
alpha=1,
|
||||
pointable = false,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.on,
|
||||
offstate = "mesetec:ladder",
|
||||
rules = mesetec.rules
|
||||
}},
|
||||
})
|
||||
|
||||
minetest.register_node("mesetec:delayer", {
|
||||
description = "Delayer (Punch to change time)",
|
||||
tiles = {"mesetec_delayer.png","default_sandstone_block.png"},
|
||||
groups = {dig_immediate = 2,mesecon=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drawtype="nodebox",
|
||||
node_box = {
|
||||
type="fixed",
|
||||
fixed={-0.5,-0.5,-0.5,0.5,-0.4,0.5}},
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.on,
|
||||
offstate = "mesetec:ladder",
|
||||
rules = mesetec.rules
|
||||
}},
|
||||
on_punch = function(pos, node, player, pointed_thing)
|
||||
if minetest.is_protected(pos, player:get_player_name())==false then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local time=meta:get_int("time")
|
||||
if time>=10 then time=0 end
|
||||
meta:set_int("time",time+1)
|
||||
meta:set_string("infotext","Delayer (" .. (time+1) ..")")
|
||||
end
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("time",1)
|
||||
meta:set_string("infotext","Delayer (1)")
|
||||
meta:set_int("case",0)
|
||||
end,
|
||||
on_timer = function (pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("case")==2 then
|
||||
meta:set_int("case",0)
|
||||
mesecon.receptor_off(pos)
|
||||
end
|
||||
if meta:get_int("case")==1 then
|
||||
meta:set_int("case",2)
|
||||
mesecon.receptor_on(pos)
|
||||
minetest.get_node_timer(pos):start(meta:get_int("time"))
|
||||
end
|
||||
return false
|
||||
end,
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("case")==0 then
|
||||
meta:set_int("case",1)
|
||||
minetest.get_node_timer(pos):start(meta:get_int("time"))
|
||||
end
|
||||
|
||||
end,
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_node("mesetec:light", {
|
||||
description = "Light check",
|
||||
tiles = {"jeija_solar_panel.png","default_steel_block.png"},
|
||||
groups = {dig_immediate = 2,mesecon=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drawtype="nodebox",
|
||||
node_box = {
|
||||
type="fixed",
|
||||
fixed={-0.5,-0.5,-0.5,0.5,-0.4,0.5}},
|
||||
is_ground_content = false,
|
||||
mesecons = {receptor = {
|
||||
rules = mesecon.rules.buttonlike_get,
|
||||
rules = mesetec.rules
|
||||
}},
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
if minetest.is_protected(pos, player:get_player_name())==false then
|
||||
mesetec.form1(pos,player,"num")
|
||||
end
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext","Light")
|
||||
end,
|
||||
on_timer = function (pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local l=meta:get_int("light")
|
||||
local rl=minetest.get_node_light(pos)
|
||||
meta:set_string("infotext","Light: " .. rl)
|
||||
if l==rl then
|
||||
mesecon.receptor_on(pos)
|
||||
else
|
||||
mesecon.receptor_off(pos)
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
BIN
screenshot.png
Normal file
After Width: | Height: | Size: 47 KiB |
366
teleob.lua
Normal file
@ -0,0 +1,366 @@
|
||||
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
|
||||
if mesetec.nodeswitch_user then
|
||||
local name=placer:get_player_name()
|
||||
if mesetec.nodeswitch_user[name] then
|
||||
if minetest.get_item_group(newnode.name,"liquid")>0 then
|
||||
return
|
||||
elseif mesetec.nodeswitch_user[name].p1 then
|
||||
minetest.add_entity(pos, "mesetec:pos2"):get_luaentity().user=name
|
||||
mesetec.nodeswitch_user[name].p2=pos
|
||||
mesetec.nodeswitch_user[name].node2=newnode.name
|
||||
mesetec.consnodeswitch(name)
|
||||
else
|
||||
minetest.add_entity(pos, "mesetec:pos1"):get_luaentity().user=name
|
||||
minetest.add_entity(pos, "mesetec:pos1")
|
||||
mesetec.nodeswitch_user[name].p1=pos
|
||||
mesetec.nodeswitch_user[name].node1=newnode.name
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
|
||||
if mesetec.nodeswitch_user then
|
||||
local name=puncher:get_player_name()
|
||||
if mesetec.nodeswitch_user[name] then
|
||||
if minetest.get_node(pointed_thing.above).name~="air" then
|
||||
return
|
||||
elseif mesetec.nodeswitch_user[name].p1 then
|
||||
if mesetec.nodeswitch_user[name].pun then
|
||||
minetest.chat_send_player(name, "A node is already punched")
|
||||
end
|
||||
minetest.add_entity(pointed_thing.above, "mesetec:pos2"):get_luaentity().user=name
|
||||
mesetec.nodeswitch_user[name].p2=pointed_thing.above
|
||||
mesetec.nodeswitch_user[name].node2=minetest.get_node(pointed_thing.above).name
|
||||
mesetec.consnodeswitch(name)
|
||||
else
|
||||
minetest.add_entity(pointed_thing.above, "mesetec:pos1"):get_luaentity().user=name
|
||||
mesetec.nodeswitch_user[name].p1=pointed_thing.above
|
||||
mesetec.nodeswitch_user[name].pun=1
|
||||
mesetec.nodeswitch_user[name].node1=minetest.get_node(pointed_thing.above).name
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
mesetec.consnodeswitch=function(name)
|
||||
if mesetec.nodeswitch_user[name].p1 and mesetec.nodeswitch_user[name].p2 then
|
||||
local meta=minetest.get_meta(mesetec.nodeswitch_user[name].pos)
|
||||
local npos1=mesetec.nodeswitch_user[name].p1
|
||||
local npos2=mesetec.nodeswitch_user[name].p2
|
||||
minetest.get_meta(npos1):set_string("mesetec_nodeswitch",name)
|
||||
minetest.get_meta(npos2):set_string("mesetec_nodeswitch",name)
|
||||
meta:set_string("node1",mesetec.nodeswitch_user[name].node1)
|
||||
meta:set_string("node2",mesetec.nodeswitch_user[name].node2)
|
||||
meta:set_string("pos1",minetest.pos_to_string(npos1))
|
||||
meta:set_string("pos2",minetest.pos_to_string(npos2))
|
||||
meta:set_int("able",1)
|
||||
mesetec.nodeswitch_user[name]=nil
|
||||
if #mesetec.nodeswitch_user==0 then mesetec.nodeswitch_user=nil end
|
||||
end
|
||||
end
|
||||
|
||||
mesetec.consnodeswitch_switch=function(pos,state)
|
||||
local meta=minetest.get_meta(pos)
|
||||
if meta:get_int("able")==0 then return end
|
||||
local pos1=minetest.string_to_pos(meta:get_string("pos1"))
|
||||
local pos2=minetest.string_to_pos(meta:get_string("pos2"))
|
||||
local node1=meta:get_string("node1")
|
||||
local node2=meta:get_string("node2")
|
||||
local owner=meta:get_string("owner")
|
||||
local meta1=minetest.get_meta(pos1)
|
||||
local meta2=minetest.get_meta(pos2)
|
||||
if minetest.is_protected(pos1, owner)
|
||||
or minetest.is_protected(pos2, owner)
|
||||
or meta1:get_string("mesetec_nodeswitch")~=owner
|
||||
or meta2:get_string("mesetec_nodeswitch")~=owner then
|
||||
meta:set_int("able",0)
|
||||
return
|
||||
end
|
||||
meta1=meta1:to_table()
|
||||
meta2=meta2:to_table()
|
||||
local n1=minetest.get_node(pos1)
|
||||
local n2=minetest.get_node(pos2)
|
||||
if not ((state==1 and node1==n1.name and node2==n2.name) or (state==2 and node1==n2.name and node2==n1.name)) then
|
||||
meta:set_int("able",0)
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos2,n1)
|
||||
minetest.get_meta(pos2):from_table(meta1)
|
||||
minetest.set_node(pos1,n2)
|
||||
minetest.get_meta(pos1):from_table(meta2)
|
||||
end
|
||||
minetest.register_node("mesetec:nodeswitch", {
|
||||
description = "Node switch",
|
||||
after_place_node = function(pos, placer)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local p=placer:get_player_name()
|
||||
meta:set_string("owner",p)
|
||||
minetest.chat_send_player(p, "Place the 1 or 2 nodes to replace with each other")
|
||||
minetest.chat_send_player(p, "Or punch somwehere to move the node to there")
|
||||
|
||||
|
||||
if not mesetec.nodeswitch_user then mesetec.nodeswitch_user={} end
|
||||
|
||||
minetest.after(0.1, function(p)
|
||||
mesetec.nodeswitch_user[p]={pos=pos,name=p}
|
||||
end, p)
|
||||
|
||||
minetest.after(60, function(p)
|
||||
if mesetec.nodeswitch_user then
|
||||
if mesetec.nodeswitch_user[p] then mesetec.nodeswitch_user[p]=nil end
|
||||
if #mesetec.nodeswitch_user==0 then mesetec.nodeswitch_user=nil end
|
||||
end
|
||||
end, p)
|
||||
end,
|
||||
|
||||
|
||||
tiles = {"default_steel_block.png"},
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
--mesecons = {receptor = {state = "off"}},
|
||||
|
||||
mesecons = {
|
||||
receptor = {state = "off"},
|
||||
effector = {
|
||||
action_on = function (pos, node)
|
||||
mesetec.consnodeswitch_switch(pos,1)
|
||||
return false
|
||||
end,
|
||||
action_off = function (pos, node)
|
||||
mesetec.consnodeswitch_switch(pos,2)
|
||||
return false
|
||||
end
|
||||
}}
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_node("mesetec:objdec", {
|
||||
description = "Object detector",
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
mesetec.form1(pos,player,"obj")
|
||||
end,
|
||||
tiles = {"default_steel_block.png","jeija_object_detector_off.png^[transform2"},
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
mesecons = {receptor = {state = "off"}},
|
||||
on_construct = function(pos)
|
||||
if not mesecon then return false end
|
||||
minetest.get_node_timer(pos):start(3)
|
||||
end,
|
||||
on_timer = function (pos, elapsed)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local data=meta:get_string("data")
|
||||
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 5)) do
|
||||
if ob and ob:get_luaentity() and (data=="" or (ob:get_luaentity().name==data)) then
|
||||
mesecon.receptor_on(pos)
|
||||
minetest.swap_node(pos, {name="mesetec:objdec2"})
|
||||
minetest.get_node_timer(pos):start(2)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("mesetec:objdec2", {
|
||||
description = "Object detector",
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
mesetec.form1(pos,player,"obj")
|
||||
end,
|
||||
tiles = {"default_steel_block.png","jeija_object_detector_on.png^[transform2"},
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
mesecons = {receptor = {state = "on"}},
|
||||
on_timer = function (pos, elapsed)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local data=meta:get_string("data")
|
||||
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 5)) do
|
||||
if ob and ob:get_luaentity() and (data=="" or (ob:get_luaentity().name==data)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
mesecon.receptor_off(pos)
|
||||
minetest.swap_node(pos, {name="mesetec:objdec"})
|
||||
minetest.get_node_timer(pos):start(3)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_node("mesetec:mtp", {
|
||||
description = "Mese teleport",
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
mesetec.form1(pos,player,"pos")
|
||||
end,
|
||||
tiles = {"mesetec_ttp.png"},
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.4375, -0.5, -0.4375, 0.4375, -0.3125, 0.4375},
|
||||
}
|
||||
},
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local po=mesetec.strpos(meta:get_string("data"),true)
|
||||
if po~=nil and minetest.get_node(po) and minetest.get_node(po).name=="mesetec:mtptarget" then
|
||||
mesecon.receptor_on(po)
|
||||
end
|
||||
return false
|
||||
end,
|
||||
action_off = function (pos, node)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local po=mesetec.strpos(meta:get_string("data"),true)
|
||||
if po~=nil and minetest.get_node(po) and minetest.get_node(po).name=="mesetec:mtptarget" then
|
||||
mesecon.receptor_off(po)
|
||||
end
|
||||
return false
|
||||
end,
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_node("mesetec:mtptarget", {
|
||||
description = "Mese teleport target",
|
||||
tiles = {"mesetec_ttp_target.png"},
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.4375, -0.5, -0.4375, 0.4375, -0.3125, 0.4375},
|
||||
}
|
||||
},
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off,
|
||||
onstate = "mesetec:mtptarget",
|
||||
}},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("mesetec:ptp", {
|
||||
description = "Player teleport",
|
||||
tiles = {"mesetec_ptp.png"},
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
local names={}
|
||||
local ii=1
|
||||
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 5)) do
|
||||
if ob then
|
||||
names[i]=ob
|
||||
ii=ii+1
|
||||
end
|
||||
end
|
||||
if names[1]==nil then return false end
|
||||
mesetec.player_teleport.targets=names
|
||||
minetest.after((1), function(pos)
|
||||
if mesetec.player_teleport.targets then
|
||||
mesetec.player_teleport.targets=nil
|
||||
end
|
||||
end, pos)
|
||||
return false
|
||||
end,
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_node("mesetec:ptptarget", {
|
||||
description = "Player teleport target",
|
||||
tiles = {"mesetecptp_target.png"},
|
||||
groups = {mesecon=2,snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
if mesetec.player_teleport.targets then
|
||||
for i, ob in pairs(mesetec.player_teleport.targets) do
|
||||
if ob then
|
||||
ob:moveto(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
mesetec.player_teleport.targets=nil
|
||||
return false
|
||||
end,
|
||||
}},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
alpha = 210,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 1.5, 0.5},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_entity("mesetec:pos1",{
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
collisionbox = {-0.52,-0.52,-0.52, 0.52,0.52,0.52},
|
||||
visual_size = {x=1.05, y=1.05},
|
||||
visual = "cube",
|
||||
textures = {"mesetec_pos1.png","mesetec_pos1.png","mesetec_pos1.png","mesetec_pos1.png","mesetec_pos1.png","mesetec_pos1.png"},
|
||||
is_visible = true,
|
||||
on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
if self.timer<1 then return self end
|
||||
self.timer=0
|
||||
self.timer2=self.timer2+dtime
|
||||
if self.timer2>2 or not (mesetec.nodeswitch_user and mesetec.nodeswitch_user[self.user]) then
|
||||
self.object:remove()
|
||||
return self
|
||||
end
|
||||
end,
|
||||
timer=0,
|
||||
timer2=0,
|
||||
user=""
|
||||
})
|
||||
|
||||
minetest.register_entity("mesetec:pos2",{
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
collisionbox = {-0.52,-0.52,-0.52, 0.52,0.52,0.52},
|
||||
visual_size = {x=1.05, y=1.05},
|
||||
visual = "cube",
|
||||
textures = {"mesetec_pos2.png","mesetec_pos2.png","mesetec_pos2.png","mesetec_pos2.png","mesetec_pos2.png","mesetec_pos2.png"},
|
||||
is_visible = true,
|
||||
on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
if self.timer<1 then return self end
|
||||
self.timer=0
|
||||
self.timer2=self.timer2+dtime
|
||||
if self.timer2>2 or not (mesetec.nodeswitch_user and mesetec.nodeswitch_user[self.user]) then
|
||||
self.object:remove()
|
||||
return self
|
||||
end
|
||||
end,
|
||||
timer=0,
|
||||
timer2=0,
|
||||
user=""
|
||||
})
|
BIN
textures/mesetec_code.png
Normal file
After Width: | Height: | Size: 235 B |
BIN
textures/mesetec_control.png
Normal file
After Width: | Height: | Size: 503 B |
BIN
textures/mesetec_delayer.png
Normal file
After Width: | Height: | Size: 856 B |
BIN
textures/mesetec_hack.png
Normal file
After Width: | Height: | Size: 549 B |
BIN
textures/mesetec_hid.png
Normal file
After Width: | Height: | Size: 133 B |
BIN
textures/mesetec_pos1.png
Normal file
After Width: | Height: | Size: 230 B |
BIN
textures/mesetec_pos2.png
Normal file
After Width: | Height: | Size: 237 B |
BIN
textures/mesetec_ptp.png
Normal file
After Width: | Height: | Size: 445 B |
BIN
textures/mesetec_trap.png
Normal file
After Width: | Height: | Size: 168 B |
BIN
textures/mesetec_trap2.png
Normal file
After Width: | Height: | Size: 165 B |
BIN
textures/mesetec_ttp.png
Normal file
After Width: | Height: | Size: 440 B |
BIN
textures/mesetec_ttp_target.png
Normal file
After Width: | Height: | Size: 488 B |
BIN
textures/mesetecptp_keycard.png
Normal file
After Width: | Height: | Size: 564 B |
BIN
textures/mesetecptp_target.png
Normal file
After Width: | Height: | Size: 451 B |
113
tools.lua
Normal file
@ -0,0 +1,113 @@
|
||||
minetest.register_tool("mesetec:controller", {
|
||||
description = "Mese teleport target controller",
|
||||
inventory_image = "mesetec_control.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local name=user:get_player_name()
|
||||
if pointed_thing.type=="node" and minetest.get_node(pointed_thing.under).name=="mesetec:mtptarget" and minetest.is_protected(pointed_thing.under, name)==false then
|
||||
local pos=pointed_thing.under
|
||||
local item=itemstack:to_table()
|
||||
local meta=minetest.deserialize(item["metadata"])
|
||||
local mode=mesetec.strpos(pos,false)
|
||||
meta={}
|
||||
meta.mode=mesetec.strpos(pos,false)
|
||||
mode=(meta.mode)
|
||||
meta.mode=mode
|
||||
item.metadata=minetest.serialize(meta)
|
||||
itemstack:replace(item)
|
||||
minetest.chat_send_player(user:get_player_name(), "Target set!")
|
||||
else
|
||||
local item=itemstack:to_table()
|
||||
local meta=minetest.deserialize(item["metadata"])
|
||||
|
||||
if meta==nil then
|
||||
minetest.chat_send_player(user:get_player_name(), "Punch a Mese teleport target")
|
||||
return itemstack
|
||||
end
|
||||
local pos=mesetec.strpos(meta.mode,true)
|
||||
local t_pos=mesetec.distance(pos,user:get_pos())
|
||||
if t_pos>mesetec.mtp_distance then
|
||||
minetest.chat_send_player(name, "Error: too faraway (max: " .. mesetec.mtp_distance ..", current: " .. (math.floor(t_pos+0.5)) .. ")")
|
||||
return itemstack
|
||||
end
|
||||
mesecon.receptor_on(pos)
|
||||
minetest.after(1, function(pos)
|
||||
mesecon.receptor_off(pos)
|
||||
end, pos)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_tool("mesetec:hacktool", {
|
||||
description = "Mese hack tool",
|
||||
inventory_image = "mesetec_hack.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local pos=user:get_pos()
|
||||
local name=user:get_player_name()
|
||||
if pointed_thing.type=="node" and minetest.is_protected(pointed_thing.under, name)==false then
|
||||
pos=pointed_thing.under
|
||||
local node=minetest.get_node(pos)
|
||||
mesecon.receptor_on(pos)
|
||||
minetest.after(1, function(pos,node)
|
||||
mesecon.receptor_off(pos)
|
||||
end, pos, node)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_tool("mesetec:keycard", {
|
||||
description = "Keycard",
|
||||
inventory_image = "mesetecptp_keycard.png",
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
local name=user:get_player_name()
|
||||
if pointed_thing.type=="node" and minetest.get_node(pointed_thing.under).name=="mesetec:codelock" then
|
||||
local pos=pointed_thing.under
|
||||
local nmeta=minetest.get_meta(pos)
|
||||
local owner=nmeta:get_string("owner")
|
||||
if owner~=name then return itemstack end
|
||||
local t_item=itemstack:to_table()
|
||||
local t_meta=minetest.deserialize(t_item["metadata"])
|
||||
if t_meta and t_meta.owner and t_meta.owner~=owner then return itemstack end
|
||||
local item=itemstack:to_table()
|
||||
local code=nmeta:get_string("data")
|
||||
local meta={}
|
||||
meta.code=code
|
||||
meta.owner=owner
|
||||
item.metadata=minetest.serialize(meta)
|
||||
itemstack:replace(item)
|
||||
minetest.chat_send_player(user:get_player_name(), "Keycard coded")
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local item=itemstack:to_table()
|
||||
local meta=minetest.deserialize(item["metadata"])
|
||||
if meta==nil then
|
||||
minetest.chat_send_player(user:get_player_name(), "Punch a codelock")
|
||||
return itemstack
|
||||
end
|
||||
if pointed_thing.type=="node" and minetest.get_node(pointed_thing.under).name=="mesetec:codelock" then
|
||||
local pos=pointed_thing.under
|
||||
local nmeta=minetest.get_meta(pos)
|
||||
local owner=nmeta:get_string("owner")
|
||||
local code=nmeta:get_string("data")
|
||||
if owner~=meta.owner or code~=meta.code then
|
||||
return itemstack
|
||||
end
|
||||
local node=minetest.get_node(pos)
|
||||
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||
minetest.after(1, function(pos,node)
|
||||
mesecon.receptor_off(pos, mesecon.rules.buttonlike_get(node))
|
||||
end, pos,node)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|