diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2016-08-15 18:23:59 -0700 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2016-08-15 18:23:59 -0700 |
commit | 5d228f0cda917b3d22cce43bdeebc5cf19662753 (patch) | |
tree | 396fbe568e52d9d2670b0722e4ed7458ac5dd335 |
First commit
-rw-r--r-- | depends.txt | 1 | ||||
-rw-r--r-- | init.lua | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..a18cd91 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +areas diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3371dfc --- /dev/null +++ b/init.lua @@ -0,0 +1,27 @@ +-- This small mod transitions the protector_redo mod to the areas. +local r = 7 +minetest.register_abm({ + nodenames = {"protector:protect", "protector:protect2", "protector:protect_sell"}, + interval = 8, + chance = 1, + catch_up = false, + action = function(pos, node) + local meta = minetest.get_meta(pos) + local name = meta:get_string("owner") + local pos1 = {x = pos.x - r, y = pos.y - r, z = pos.z - r} + local pos2 = {x = pos.x + r, y = pos.y + r, z = pos.z + r} + if not (pos1 and pos2) then + return false, "You need to select an area first." + end + + minetest.log("action", "/protect invoked, owner="..name.. + " AreaName=".."Converted from protectors".. + " StartPos="..minetest.pos_to_string(pos1).. + " EndPos=" ..minetest.pos_to_string(pos2)) + local id = areas:add(name, "Converted from Protectors", pos1, pos2, nil) + areas:save() + minetest.chat_send_all("Area protected. ID: "..id) + minetest.set_node(pos, {name = "markers:stone"}) + return true + end +}) |