Subcmd: flags cmd

This commit is contained in:
Coder12a 2020-01-02 18:58:16 -06:00
parent 8e2a92b792
commit 3b1d02fd33
2 changed files with 55 additions and 47 deletions

View File

@ -176,12 +176,7 @@ factions.register_command("flag", {
description = "Manage the faction's flags.",
description_arg = " <flag> <value>:",
global_privileges = def_global_privileges,
format = {"string"},
ignore_param_limit = true,
on_success = function(player, faction, pos, parcelpos, args)
local flag_name = args.strings[1]
local bool = args.strings[2]
if (flag_name == "help" or flag_name == "flags") or not bool then
local msg = ""
for i, k in pairs(factions.flags) do
msg = msg .. i ..": ".. k .. "\n"
@ -189,27 +184,6 @@ factions.register_command("flag", {
minetest.chat_send_player(player, msg)
return true
end
if flag_name and bool then
local yes = false
if bool == "yes" then
yes = true
elseif bool == "no" then
yes = false
else
minetest.chat_send_player(player, "Set the flags only to yes or no.")
return false
end
if flag_name == "open" then
factions.toggle_join_free(faction.name, yes)
elseif flag_name == "monsters" then
elseif flag_name == "tax_kick" then
elseif flag_name == "animals" then
else
minetest.chat_send_player(player, flag_name.." is not an flag.")
end
end
return true
end
})
factions.register_command("desc", {
format = {"string"},

View File

@ -184,3 +184,37 @@ factions.register_command ({"unclaim h", "unclaim help"}, {
factions.unclaim_help(player, arg_two)
end
})
factions.register_command({"flag help", "flag flags"}, {
faction_permissions = {"flags"},
global_privileges = def_global_privileges,
dont_show_in_help = true,
on_success = function(player, faction, pos, parcelpos, args)
local msg = ""
for i, k in pairs(factions.flags) do
msg = msg .. i ..": ".. k .. "\n"
end
minetest.chat_send_player(player, msg)
end
})
factions.register_command("flag open", {
faction_permissions = {"flags"},
global_privileges = def_global_privileges,
dont_show_in_help = true,
format = {"string"},
on_success = function(player, faction, pos, parcelpos, args)
local bool = args.strings[1]
if bool then
local yes = false
if bool == "yes" then
yes = true
elseif bool == "no" then
yes = false
else
minetest.chat_send_player(player, "Set the flags only to yes or no.")
return false
end
factions.toggle_join_free(faction.name, yes)
end
end
})