tweak protector_remove and add protector_replace commands
This commit is contained in:
parent
cfbe158cb2
commit
71782e27ab
2 changed files with 85 additions and 15 deletions
18
README.md
18
README.md
|
|
@ -53,20 +53,32 @@ Usage: (requires server privelage)
|
||||||
|
|
||||||
list names to remove
|
list names to remove
|
||||||
|
|
||||||
/delprot
|
/protector_remove
|
||||||
|
|
||||||
remove specific user names
|
remove specific user names
|
||||||
|
|
||||||
/delprot name1 name2
|
/protector_remove name1 name2
|
||||||
|
|
||||||
remove all names from list
|
remove all names from list
|
||||||
|
|
||||||
/delprot -
|
/protector_remove -
|
||||||
|
|
||||||
Whenever a player is near any protectors with name1 or name2 then it will be
|
Whenever a player is near any protectors with name1 or name2 then it will be
|
||||||
replaced by an air block.
|
replaced by an air block.
|
||||||
|
|
||||||
|
|
||||||
|
show owner name to replace
|
||||||
|
|
||||||
|
/protector_replace
|
||||||
|
|
||||||
|
replace owner with new name
|
||||||
|
|
||||||
|
/protector_replace owner new_owner
|
||||||
|
|
||||||
|
reset name list
|
||||||
|
/protector_replace -
|
||||||
|
|
||||||
|
|
||||||
The following lines can be added to your minetest.conf file to configure specific features of the mod:
|
The following lines can be added to your minetest.conf file to configure specific features of the mod:
|
||||||
|
|
||||||
protector_radius = 5
|
protector_radius = 5
|
||||||
|
|
|
||||||
82
admin.lua
82
admin.lua
|
|
@ -2,23 +2,25 @@
|
||||||
local S = protector.intllib
|
local S = protector.intllib
|
||||||
|
|
||||||
protector.removal_names = ""
|
protector.removal_names = ""
|
||||||
|
protector.replace_names = ""
|
||||||
|
|
||||||
minetest.register_chatcommand("delprot", {
|
minetest.register_chatcommand("protector_remove", {
|
||||||
params = "",
|
params = "<names list>",
|
||||||
description = S("Remove Protectors near players with names provided (separate names with spaces)"),
|
description = S("Remove Protectors around players (separate names with spaces)"),
|
||||||
privs = {server = true},
|
privs = {server = true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
|
|
||||||
if not param or param == "" then
|
if not param or param == "" then
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
S("Protector Names to remove: %1",
|
"Protector Names to remove: "
|
||||||
protector.removal_names))
|
.. protector.removal_names)
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if param == "-" then
|
if param == "-" then
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
S("Name List Reset"))
|
S("Name List Reset"))
|
||||||
|
|
||||||
|
|
@ -32,6 +34,48 @@ minetest.register_chatcommand("delprot", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_chatcommand("protector_replace", {
|
||||||
|
params = "<owner name> <name to replace with>",
|
||||||
|
description = S("Replace Protector Owner with name provided"),
|
||||||
|
privs = {server = true},
|
||||||
|
func = function(name, param)
|
||||||
|
|
||||||
|
if not param or param == "" then
|
||||||
|
|
||||||
|
if protector.replace_names ~= "" then
|
||||||
|
|
||||||
|
local names = protector.replace_names:split(" ")
|
||||||
|
|
||||||
|
minetest.chat_send_player(name,
|
||||||
|
"Replacing Protector name '" .. names[1]
|
||||||
|
.. "' with '" .. names[2] .. "'")
|
||||||
|
|
||||||
|
return
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(name,
|
||||||
|
"Usage: /protector_replace <owner name> <new owner name>")
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if param == "-" then
|
||||||
|
|
||||||
|
minetest.chat_send_player(name,
|
||||||
|
S("Name List Reset"))
|
||||||
|
|
||||||
|
protector.replace_names = ""
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
protector.replace_names = param
|
||||||
|
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"protector:protect", "protector:protect2"},
|
nodenames = {"protector:protect", "protector:protect2"},
|
||||||
interval = 8,
|
interval = 8,
|
||||||
|
|
@ -39,23 +83,37 @@ minetest.register_abm({
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
|
|
||||||
if protector.removal_names == "" then
|
if protector.removal_names == ""
|
||||||
|
and protector_replace_names == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos) ; if not meta then return end
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
--local members = meta:get_string("members")
|
--local members = meta:get_string("members")
|
||||||
|
|
||||||
local names = protector.removal_names:split(" ")
|
if protector.removal_names ~= "" then
|
||||||
|
|
||||||
for _, n in pairs(names) do
|
local names = protector.removal_names:split(" ")
|
||||||
|
|
||||||
if n == owner then
|
for _, n in pairs(names) do
|
||||||
minetest.set_node(pos, {name = "air"})
|
|
||||||
|
if n == owner then
|
||||||
|
minetest.set_node(pos, {name = "air"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if protector.replace_names ~= "" then
|
||||||
|
|
||||||
|
local names = protector.replace_names:split(" ")
|
||||||
|
|
||||||
|
if owner == names[1] then
|
||||||
|
|
||||||
|
meta:set_string("owner", names[2])
|
||||||
|
meta:set_string("infotext", "Protection (owned by " .. names[2] .. ")")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue