diff options
author | TenPlus1 <kinsellaja@yahoo.com> | 2017-06-24 10:46:15 +0100 |
---|---|---|
committer | TenPlus1 <kinsellaja@yahoo.com> | 2017-06-24 10:46:15 +0100 |
commit | 38341294e786634b61af978be3c37deff6489fb5 (patch) | |
tree | 55ef236723f4e687a7ac4ae9d0a5b490c9bb5ceb | |
parent | 1130f447a62cdcb40fe24d68b7717eaa55b1f9bb (diff) |
add nil checks to /protector_replace command
-rw-r--r-- | admin.lua | 32 |
1 files changed, 13 insertions, 19 deletions
@@ -41,31 +41,25 @@ minetest.register_chatcommand("protector_replace", { privs = {server = true}, func = function(name, param) - if not param or param == "" then - - if protector.replace_names ~= "" then - - local names = protector.replace_names:split(" ") + -- reset list to empty + if param == "-" then - minetest.chat_send_player(name, - "Replacing Protector name '" .. names[1] - .. "' with '" .. names[2] .. "'") + minetest.chat_send_player(name, S("Name List Reset")) - return - else - minetest.chat_send_player(name, - "Usage: /protector_replace <owner name> <new owner name>") + protector.replace_names = "" - return - end + return end - if param == "-" then + -- show name info + if param == "" + and protector.replace_names ~= "" then - minetest.chat_send_player(name, - S("Name List Reset")) + local names = protector.replace_names:split(" ") - protector.replace_names = "" + minetest.chat_send_player(name, + "Replacing Protector name '" .. (names[1] or "") + .. "' with '" .. (names[2] or "").. "'") return end @@ -108,7 +102,7 @@ minetest.register_abm({ local names = protector.replace_names:split(" ") - if owner == names[1] then + if names[1] and names[2] and owner == names[1] then meta:set_string("owner", names[2]) meta:set_string("infotext", "Protection (owned by " .. names[2] .. ")") |