From 655c9036ec9bfbf1c0a47c5980b17e4b6ad70f77 Mon Sep 17 00:00:00 2001 From: elite Date: Mon, 3 Jul 2017 10:20:00 -0400 Subject: [PATCH] [protector] update --- minetest.conf | 4 +++ worldmods/protector/README.md | 4 ++- worldmods/protector/init.lua | 6 ++--- worldmods/protector/lucky_block.lua | 4 +++ worldmods/protector/tool.lua | 42 ++++++++++++++++++----------- 5 files changed, 41 insertions(+), 19 deletions(-) diff --git a/minetest.conf b/minetest.conf index 4e8e540..7bba711 100755 --- a/minetest.conf +++ b/minetest.conf @@ -39,6 +39,10 @@ playereffects_autosave = 60 enable_sprinting = true static_spawnpoint = -2770,25,2327 enable_tnt = false +protector_hurt = 0 +protector_flip = true +protector_spawn = 10 +protector_pvp = true # #################IRC################ # diff --git a/worldmods/protector/README.md b/worldmods/protector/README.md index c5cc739..dad1fab 100644 --- a/worldmods/protector/README.md +++ b/worldmods/protector/README.md @@ -48,8 +48,10 @@ Change log: Protectors and chest cannot be moved by mesecon pistons or machines. 2.1 - Added 'protector_night_pvp' setting so night-time becomes a free for all and players can hurt one another even inside protected areas (not spawn protected) +2.2 - Updated protector tool so that player only needs to stand nearby (2 block radius) + It can also place vertically (up and down) as well. New protector recipe added. -Lucky Blocks: 6 +Lucky Blocks: 10 Usage: (requires server privelage) diff --git a/worldmods/protector/init.lua b/worldmods/protector/init.lua index 9007ac1..f58afa3 100644 --- a/worldmods/protector/init.lua +++ b/worldmods/protector/init.lua @@ -424,7 +424,7 @@ minetest.register_craft({ output = "protector:protect", recipe = { {"default:stone", "default:stone", "default:stone"}, - {"default:stone", "default:steel_ingot", "default:stone"}, + {"default:stone", "default:gold_ingot", "default:stone"}, {"default:stone", "default:stone", "default:stone"}, } }) @@ -500,7 +500,7 @@ minetest.register_node("protector:protect2", { on_blast = function() end, }) - +--[[ minetest.register_craft({ output = "protector:protect2", recipe = { @@ -509,7 +509,7 @@ minetest.register_craft({ {"default:stone", "default:stone", "default:stone"}, } }) - +]] -- check formspec buttons or when name entered minetest.register_on_player_receive_fields(function(player, formname, fields) diff --git a/worldmods/protector/lucky_block.lua b/worldmods/protector/lucky_block.lua index 9484e35..59c52c1 100644 --- a/worldmods/protector/lucky_block.lua +++ b/worldmods/protector/lucky_block.lua @@ -8,6 +8,10 @@ if minetest.get_modpath("lucky_block") then {"dro", {"protector:protect2"}, 3}, {"dro", {"protector:door_wood"}, 1}, {"dro", {"protector:door_steel"}, 1}, + {"exp", 5, true}, + {"dro", {"protector:trapdoor"}, 1}, + {"dro", {"protector:trapdoor_steel"}, 1}, + {"dro", {"protector:tool"}, 1}, {"dro", {"protector:chest"}, 1}, {"exp"}, }) diff --git a/worldmods/protector/tool.lua b/worldmods/protector/tool.lua index 839112d..653ba36 100644 --- a/worldmods/protector/tool.lua +++ b/worldmods/protector/tool.lua @@ -2,26 +2,23 @@ -- protector placement tool (thanks to Shara for code and idea) minetest.register_craftitem("protector:tool", { - description = "Protector Placer Tool (stand on protector, face direction and use)", - inventory_image = "protector_display.png", + description = "Protector Placer Tool (stand near protector, face direction and use)", + inventory_image = "protector_display.png^protector_logo.png", stack_max = 1, on_use = function(itemstack, user, pointed_thing) local name = user:get_player_name() - -- check node player occupies + -- check for protector near player (2 block radius) local pos = user:getpos() - local nod = minetest.get_node(pos).name - if nod ~= "protector:protect2" then - -- check node under player - pos.y = pos.y - 1 - nod = minetest.get_node(pos).name - if nod ~= "protector:protect" - and nod ~= "protector:protect2" then - return - end - end + local pp = minetest.find_nodes_in_area( + vector.subtract(pos, 2), vector.add(pos, 2), + {"protector:protect", "protector:protect2"}) + + if #pp == 0 then return end -- none found + + pos = pp[1] -- take position of first protector found -- get members on protector local meta = minetest.get_meta(pos) @@ -31,9 +28,14 @@ minetest.register_craftitem("protector:tool", { local dir = minetest.dir_to_facedir( user:get_look_dir() ) local vec = {x = 0, y = 0, z = 0} local gap = (protector.radius * 2) + 1 + local pit = user:get_look_pitch() -- set placement coords - if dir == 0 then + if pit > 1.2 then + vec.y = gap -- up + elseif pit < -1.2 then + vec.y = -gap -- down + elseif dir == 0 then vec.z = gap -- north elseif dir == 1 then vec.x = gap -- east @@ -68,6 +70,7 @@ minetest.register_craftitem("protector:tool", { end -- do we have protectors to use ? + local nod local inv = user:get_inventory() if not inv:contains_item("main", "protector:protect") @@ -76,11 +79,16 @@ minetest.register_craftitem("protector:tool", { return end - -- take protector + -- take protector (block first then logo) if inv:contains_item("main", "protector:protect") then + inv:remove_item("main", "protector:protect") + nod = "protector:protect" + elseif inv:contains_item("main", "protector:protect2") then + inv:remove_item("main", "protector:protect2") + nod = "protector:protect2" end -- place protector @@ -88,6 +96,7 @@ minetest.register_craftitem("protector:tool", { -- set protector metadata local meta = minetest.get_meta(pos) + meta:set_string("owner", name) meta:set_string("infotext", "Protection (owned by " .. name .. ")") @@ -98,6 +107,9 @@ minetest.register_craftitem("protector:tool", { meta:set_string("members", "") end + minetest.chat_send_player(name, + "Protector placed at " .. minetest.pos_to_string(pos)) + end, })