diff options
author | Novatux <nathanael.courant@laposte.net> | 2013-10-06 14:20:13 +0200 |
---|---|---|
committer | Novatux <nathanael.courant@laposte.net> | 2013-10-13 10:34:58 +0200 |
commit | 3cf0d331f0f12155fcef970a1000b5e879e91b14 (patch) | |
tree | 66f13c358174dcc99234ce8897258bcc74b8b5d5 | |
parent | c06cdf603ef0e685a5c86baf950ab68757798682 (diff) |
Make template motors have an owner and check area protection
-rw-r--r-- | technic/machines/other/frames.lua | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/technic/machines/other/frames.lua b/technic/machines/other/frames.lua index 6fd7b98..9f2fbfa 100644 --- a/technic/machines/other/frames.lua +++ b/technic/machines/other/frames.lua @@ -58,7 +58,15 @@ local function add_table(table,toadd) table[i]=toadd end -local function move_nodes_vect(poslist,vect,must_not_move) +local function move_nodes_vect(poslist,vect,must_not_move,owner) + if minetest.is_protected then + for _,pos in ipairs(poslist) do + local npos=frames.addVect(pos,vect) + if minetest.is_protected(pos, owner) or minetest.is_protected(npos, owner) then + return + end + end + end for _,pos in ipairs(poslist) do local npos=vector.add(pos,vect) local name = minetest.env:get_node(npos).name @@ -245,7 +253,6 @@ local function frame_motor_on(pos, node) local nnode=minetest.get_node(nnodepos) local meta = minetest.get_meta(pos) local owner = meta:get_string("owner") - print(node.param2) if minetest.registered_nodes[nnode.name].frame==1 then local connected_nodes=get_connected_nodes(nnodepos) move_nodes_vect(connected_nodes,dir,pos,owner) @@ -446,10 +453,11 @@ local function template_motor_on(pos, node) local nnodepos = vector.add(pos, dirs[math.floor(node.param2/4)+1]) local dir = minetest.facedir_to_dir(node.param2) local nnode=minetest.get_node(nnodepos) - --if minetest.registered_nodes[nnode.name].template==1 then + local meta = minetest.get_meta(pos) + local owner = meta:get_string("owner") if nnode.name == "technic:template" then local connected_nodes=get_template_nodes(nnodepos) - move_nodes_vect(connected_nodes,dir,pos) + move_nodes_vect(connected_nodes,dir,pos,owner) end end @@ -460,4 +468,8 @@ minetest.register_node("technic:template_motor",{ groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2}, paramtype2 = "facedir", mesecons={effector={action_on=template_motor_on}}, + after_place_node = function(pos, placer, itemstack) + local meta = minetest.get_meta(pos) + meta:set_string("owner", placer:get_player_name()) + end, }) |