mirror of
https://notabug.org/TenPlus1/protector.git
synced 2024-12-05 03:03:48 +01:00
Added 'protector_msg' setting for player messages
This commit is contained in:
parent
e7117e4c3d
commit
0702fad2db
@ -59,7 +59,7 @@ Change log:
|
||||
- 2.9 - Added MineClone2 recipes for protection block but no official support as yet
|
||||
- 3.0 - Added PlayerFactions support, 'protector_hud_interval' setting and listing in advanced settings for mod values.
|
||||
- 3.1 - Ability to hide protection blocks using /protector_hide and /protector_show , italian local added (thanks Hamlet)
|
||||
- 3.2 - Defaults to Minetest translation if found, otherwise intllib fallback if loaded, locale files updated for both.
|
||||
- 3.2 - Defaults to Minetest translation if found, otherwise intllib fallback if loaded, locale files updated for both. Added 'protector_msg' setting for player text.
|
||||
|
||||
Lucky Blocks: 10
|
||||
|
||||
@ -127,6 +127,12 @@ protector_flip = true
|
||||
protector_show_interval
|
||||
- Number of seconds the protection field is visible, defaults to 5 seconds.
|
||||
|
||||
protector_recipe = true
|
||||
- When true allows players to craft protection blocks
|
||||
|
||||
protector_msg = true
|
||||
- When true shows protection messages in players chat when trying to interact in someone else's area
|
||||
|
||||
|
||||
Protector Tool
|
||||
|
||||
|
29
init.lua
29
init.lua
@ -32,6 +32,7 @@ local protector_spawn = tonumber(minetest.settings:get("protector_spawn")
|
||||
or minetest.settings:get("protector_pvp_spawn")) or 0
|
||||
local protector_show = tonumber(minetest.settings:get("protector_show_interval")) or 5
|
||||
local protector_recipe = minetest.settings:get_bool("protector_recipe") ~= false
|
||||
local protector_msg = minetest.settings:get_bool("protector_msg") ~= false
|
||||
|
||||
-- get static spawn position
|
||||
local statspawn = minetest.string_to_pos(minetest.settings:get("static_spawnpoint"))
|
||||
@ -211,6 +212,18 @@ local inside_spawn = function(pos, radius)
|
||||
end
|
||||
|
||||
|
||||
-- show protection message if enabled
|
||||
local show_msg = function(player, msg)
|
||||
|
||||
-- if messages disabled or no player name provided
|
||||
if protector_msg == false or not player or player == "" then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.chat_send_player(player, msg)
|
||||
end
|
||||
|
||||
|
||||
-- Infolevel:
|
||||
-- 0 for no info
|
||||
-- 1 for "This area is owned by <owner> !" if you can't dig
|
||||
@ -235,7 +248,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
||||
-- is spawn area protected ?
|
||||
if inside_spawn(pos, protector_spawn) then
|
||||
|
||||
minetest.chat_send_player(digger,
|
||||
show_msg(digger,
|
||||
S("Spawn @1 has been protected up to a @2 block radius.",
|
||||
minetest.pos_to_string(statspawn), protector_spawn))
|
||||
|
||||
@ -262,7 +275,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
||||
-- and you aren't on the member list
|
||||
if onlyowner or not is_member(meta, digger) then
|
||||
|
||||
minetest.chat_send_player(digger,
|
||||
show_msg(digger,
|
||||
S("This area is owned by @1", owner) .. "!")
|
||||
|
||||
return false
|
||||
@ -429,8 +442,9 @@ minetest.register_node("protector:protect", {
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
meta:set_string("owner", placer:get_player_name() or "")
|
||||
meta:set_string("infotext", S("Protection (owned by @1)", meta:get_string("owner")))
|
||||
meta:set_string("members", "")
|
||||
meta:set_string("infotext",
|
||||
S("Protection (owned by @1)", meta:get_string("owner")))
|
||||
end,
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
@ -439,7 +453,8 @@ minetest.register_node("protector:protect", {
|
||||
return
|
||||
end
|
||||
|
||||
protector.can_dig(protector_radius, pointed_thing.under, user:get_player_name(), false, 2)
|
||||
protector.can_dig(protector_radius, pointed_thing.under,
|
||||
user:get_player_name(), false, 2)
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
@ -533,8 +548,9 @@ minetest.register_node("protector:protect2", {
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
meta:set_string("owner", placer:get_player_name() or "")
|
||||
meta:set_string("infotext", S("Protection (owned by @1)", meta:get_string("owner")))
|
||||
meta:set_string("members", "")
|
||||
meta:set_string("infotext",
|
||||
S("Protection (owned by @1)", meta:get_string("owner")))
|
||||
end,
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
@ -543,7 +559,8 @@ minetest.register_node("protector:protect2", {
|
||||
return
|
||||
end
|
||||
|
||||
protector.can_dig(protector_radius, pointed_thing.under, user:get_player_name(), false, 2)
|
||||
protector.can_dig(protector_radius, pointed_thing.under,
|
||||
user:get_player_name(), false, 2)
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
|
@ -27,3 +27,6 @@ protector_hud_interval (Protector HUD Interval) int 5
|
||||
|
||||
# Enables craft recipe for protection block
|
||||
protector_recipe (Enable Protector recipe) bool true
|
||||
|
||||
# Enables protection messages in player chat
|
||||
protector_msg (Enable Protector Messages) bool true
|
||||
|
6
tool.lua
6
tool.lua
@ -67,7 +67,8 @@ minetest.register_craftitem("protector:tool", {
|
||||
-- does a protector already exist ?
|
||||
if #minetest.find_nodes_in_area(
|
||||
vector.subtract(pos, 1), vector.add(pos, 1),
|
||||
{"protector:protect", "protector:protect2", "protector:protect_hidden"}) > 0 then
|
||||
{"protector:protect", "protector:protect2",
|
||||
"protector:protect_hidden"}) > 0 then
|
||||
|
||||
minetest.chat_send_player(name, S("Protector already in place!"))
|
||||
|
||||
@ -91,11 +92,13 @@ minetest.register_craftitem("protector:tool", {
|
||||
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
|
||||
|
||||
@ -142,6 +145,7 @@ minetest.register_craftitem("protector:tool", {
|
||||
|
||||
-- tool recipe
|
||||
local df = "default:steel_ingot"
|
||||
|
||||
if not minetest.registered_items[df] then
|
||||
df = "mcl_core:iron_ingot"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user