Combind some privs

This commit is contained in:
Coder12a 2018-12-27 01:09:41 -06:00
parent 269690d279
commit 6c3d35c9b2
2 changed files with 26 additions and 48 deletions

View File

@ -783,7 +783,7 @@ factions.register_command("show_parcel", {
factions.register_command("new_rank", {
description = "Add a new rank.",
format = {"string"},
faction_permissions = {"create_ranks"},
faction_permissions = {"ranks"},
global_privileges = def_global_privileges,
on_success = function(player, faction, pos, parcelpos, args)
if args.strings[1] then
@ -800,6 +800,8 @@ factions.register_command("new_rank", {
if f == r then
success = true
break
else
success = false
end
end
if not success and _ ~= 1 then
@ -827,7 +829,7 @@ factions.register_command("new_rank", {
factions.register_command("replace_privs", {
description = "Deletes current permissions and replaces them with the ones given.",
format = {"string"},
faction_permissions = {"edit_ranks"},
faction_permissions = {"ranks"},
global_privileges = def_global_privileges,
on_success = function(player, faction, pos, parcelpos, args)
if args.strings[1] then
@ -844,6 +846,8 @@ factions.register_command("replace_privs", {
if f == r then
success = true
break
else
success = false
end
end
if not success and _ ~= 1 then
@ -871,7 +875,7 @@ factions.register_command("replace_privs", {
factions.register_command("remove_privs", {
description = "Remove permissions from a rank.",
format = {"string"},
faction_permissions = {"edit_ranks"},
faction_permissions = {"ranks"},
global_privileges = def_global_privileges,
on_success = function(player, faction, pos, parcelpos, args)
if args.strings[1] then
@ -888,6 +892,8 @@ factions.register_command("remove_privs", {
if f == r then
success = true
break
else
success = false
end
end
if not success and _ ~= 1 then
@ -915,7 +921,7 @@ factions.register_command("remove_privs", {
factions.register_command("add_privs", {
description = "add permissions to a rank.",
format = {"string"},
faction_permissions = {"edit_ranks"},
faction_permissions = {"ranks"},
global_privileges = def_global_privileges,
on_success = function(player, faction, pos, parcelpos, args)
if args.strings[1] then
@ -932,6 +938,8 @@ factions.register_command("add_privs", {
if f == r then
success = true
break
else
success = false
end
end
if not success and _ ~= 1 then
@ -959,7 +967,7 @@ factions.register_command("add_privs", {
factions.register_command("set_rank_name", {
description = "Change the name of given rank.",
format = {"string","string"},
faction_permissions = {"edit_ranks"},
faction_permissions = {"ranks"},
global_privileges = def_global_privileges,
on_success = function(player, faction, pos, parcelpos, args)
local rank = args.strings[1]
@ -980,7 +988,7 @@ factions.register_command("set_rank_name", {
factions.register_command("del_rank", {
description = "Replace and delete a rank.",
format = {"string", "string"},
faction_permissions = {"delete_ranks"},
faction_permissions = {"ranks"},
global_privileges = def_global_privileges,
on_success = function(player, faction, pos, parcelpos, args)
local rank = args.strings[1]
@ -997,7 +1005,7 @@ factions.register_command("del_rank", {
factions.register_command("set_def_rank", {
description = "Change the default rank given to new players and also replace rankless players in this faction.",
format = {"string"},
faction_permissions = {"set_def_ranks"},
faction_permissions = {"ranks"},
global_privileges = def_global_privileges,
on_success = function(player, faction, pos, parcelpos, args)
local rank = args.strings[1]
@ -1013,7 +1021,7 @@ factions.register_command("set_def_rank", {
factions.register_command("reset_ranks", {
description = "Reset's all of the factions rankings back to the default ones.",
format = {},
faction_permissions = {"reset_ranks"},
faction_permissions = {"ranks"},
global_privileges = def_global_privileges,
on_success = function(player, faction, pos, parcelpos, args)
faction:reset_ranks()
@ -1023,7 +1031,7 @@ factions.register_command("reset_ranks", {
factions.register_command("set_spawn", {
description = "Set the faction's spawn",
faction_permissions = {"set_spawn"},
faction_permissions = {"spawn"},
global_privileges = def_global_privileges,
on_success = function(player, faction, pos, parcelpos, args)
faction:set_spawn(pos)
@ -1033,7 +1041,7 @@ factions.register_command("set_spawn", {
factions.register_command("del_spawn", {
description = "Set the faction's spawn to zero",
faction_permissions = {"unset_spawn"},
faction_permissions = {"spawn"},
global_privileges = def_global_privileges,
on_success = function(player, faction, pos, parcelpos, args)
faction:set_spawn({x=0,y=0,z=0})

View File

@ -36,8 +36,8 @@ util = {
factions.Faction.__index = factions.Faction
starting_ranks = {["leader"] = {"build","door","container","name","description","motd","invite","kick"
,"player_title","set_spawn","unset_spawn","with_draw","territory","claim","access","disband","flags","create_ranks","edit_ranks","delete_ranks","set_def_ranks","reset_ranks","promote"},
["moderator"] = {"claim","door","build","set_spawn","invite","kick","promote"},
,"player_title","spawn","with_draw","territory","claim","access","disband","flags","ranks","promote"},
["moderator"] = {"claim","door","build","spawn","invite","kick","promote"},
["member"] = {"build","container","door"}
}
@ -53,20 +53,14 @@ starting_ranks = {["leader"] = {"build","door","container","name","description",
-- invite: (un)invite players to join the faction
-- kick: kick players off the faction
-- player_title: set player titles
-- set_spawn: set the faction's spawn
-- unset_spawn: delete the faction's spawn
-- spawn: set the faction's spawn
-- with_draw: withdraw money from the faction's bank
-- spawn: be able to teleport to the faction's spawn
-- territory: claim or unclaim territory
-- claim: (un)claim parcels of land
-- access: manage access to territory and parcels of land to players or factions
-- disband: disband the faction
-- flags: manage faction's flags
-- create_ranks: create new ranks
-- edit_ranks: edit rank name and permissions
-- delete_ranks: delete ranks
-- set_def_ranks: set the default rank given to new players
-- reset_ranks: reset the ranks back to the default ones
-- ranks: create, edit, and delete ranks
-- promote: set a player's rank
-- declare_war: be able to declare war with another faction
-- neutral: be able to send a neutral request to another faction
@ -75,11 +69,11 @@ starting_ranks = {["leader"] = {"build","door","container","name","description",
-- refuse_treaty: be able to refuse a treaty request from another faction
factions.permissions = {"build","pain_build","door","container","name","description","motd","invite","kick"
,"player_title","set_spawn","unset_spawn","with_draw","territory","claim","access","disband","flags","create_ranks","edit_ranks","delete_ranks","set_def_ranks","reset_ranks","promote"}
,"player_title","spawn","with_draw","territory","claim","access","disband","flags","ranks","promote"}
factions.permissions_desc = {"dig and place nodes","dig and place nodes but take damage doing so","open/close or dig","be able to use containers like chest","set the faction's name"
,"Set the faction description","set the faction's message of the day","(un)invite players to join the faction","kick players off the faction","set player titles","set the faction's spawn"
,"delete the faction's spawn","withdraw money from the faction's bank","claim or unclaim territory","(un)claim parcels of land","manage access to territory and parcels of land to players or factions"
,"disband the faction","manage faction's flags","create new ranks","edit rank permissions","delete ranks","set the default rank given to new players","reset the ranks back to the default ones","set a player's rank"}
,"withdraw money from the faction's bank","claim or unclaim territory","(un)claim parcels of land","manage access to territory and parcels of land to players or factions"
,"disband the faction","manage faction's flags","create, edit, and delete ranks"}
-- open: can the faction be joined without an invite?
-- monsters: can monsters spawn on your land?
@ -110,17 +104,6 @@ if factions_config.faction_diplomacy == true then
starting_ranks["leader"] = lt
end
if factions_config.spawn_teleport == true then
table.insert(factions.permissions,"spawn")
table.insert(factions.permissions_desc,"be able to teleport to the faction's spawn")
table.insert(starting_ranks["leader"],"spawn")
table.insert(starting_ranks["moderator"],"spawn")
table.insert(starting_ranks["member"],"spawn")
end
function factions.Faction:new(faction)
faction = {
name = "",
@ -1195,7 +1178,7 @@ function factions.convert(filename)
file:close()
local data = minetest.deserialize(raw_data)
local old_permissions = {"disband", "claim", "playerslist", "build", "description", "ranks", "spawn", "promote","diplomacy"}
local old_permissions = {"disband", "claim", "playerslist", "build", "description", "promote", "diplomacy"}
for facname,faction in pairs(data) do
local newfac = factions.new_faction(facname,true)
@ -1224,13 +1207,6 @@ function factions.convert(filename)
table.remove(faction.ranks[rank],index)
table.insert(faction.ranks[rank],"kick")
table.insert(faction.ranks[rank],"invite")
elseif value == "ranks" then
table.remove(faction.ranks[rank],index)
table.insert(faction.ranks[rank],"create_ranks")
table.insert(faction.ranks[rank],"edit_ranks")
table.insert(faction.ranks[rank],"delete_ranks")
table.insert(faction.ranks[rank],"set_def_ranks")
table.insert(faction.ranks[rank],"reset_ranks")
elseif value == "diplomacy" then
table.remove(faction.ranks[rank],index)
table.insert(faction.ranks[rank],"declare_war")
@ -1238,12 +1214,6 @@ function factions.convert(filename)
table.insert(faction.ranks[rank],"alliance")
table.insert(faction.ranks[rank],"accept_treaty")
table.insert(faction.ranks[rank],"refuse_treaty")
elseif value == "spawn" then
if not factions_config.spawn_teleport == true then
table.remove(faction.ranks[rank],index)
end
table.insert(faction.ranks[rank],"set_spawn")
table.insert(faction.ranks[rank],"unset_spawn")
end
end
end