forked from mtcontrib/factions
Compare commits
16 Commits
785d1a534c
...
master
Author | SHA1 | Date | |
---|---|---|---|
7db1b30542 | |||
d267e7ad97 | |||
5c46eb1188 | |||
d8abcbb05b | |||
3b1d02fd33 | |||
8e2a92b792 | |||
d64425ade8 | |||
ae09c39950 | |||
ea15d7ef6f | |||
78e6d54576 | |||
52b9000960 | |||
9c4334e19c | |||
a01d80dd80 | |||
37050bf225 | |||
01a13d6b8f | |||
e16e72956f |
10
fac/init.lua
10
fac/init.lua
@ -11,18 +11,10 @@ factions.can_create_faction = function(name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
util = {
|
||||
coords3D_string = function(coords)
|
||||
return coords.x..", "..coords.y..", "..coords.z
|
||||
end
|
||||
}
|
||||
|
||||
starting_ranks = {["leader"] = {"build", "door", "container", "name", "description", "motd", "invite", "kick"
|
||||
, "spawn", "with_draw", "territory", "claim", "access", "disband", "flags", "ranks", "promote"},
|
||||
["moderator"] = {"claim", "door", "build", "spawn", "invite", "kick", "promote", "container"},
|
||||
["member"] = {"build", "container", "door"}
|
||||
}
|
||||
["member"] = {"build", "container", "door"}}
|
||||
|
||||
-- Faction permissions:
|
||||
--
|
||||
|
1214
fac_chat/commands.lua
Normal file
1214
fac_chat/commands.lua
Normal file
File diff suppressed because it is too large
Load Diff
1390
fac_chat/init.lua
1390
fac_chat/init.lua
File diff suppressed because it is too large
Load Diff
220
fac_chat/subcommands.lua
Normal file
220
fac_chat/subcommands.lua
Normal file
@ -0,0 +1,220 @@
|
||||
local def_global_privileges = nil
|
||||
if factions_config.faction_user_priv == true then
|
||||
def_global_privileges = {"faction_user"}
|
||||
end
|
||||
|
||||
factions.register_command({"claim o", "claim one"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
return claim_helper(player, faction, parcelpos)
|
||||
end
|
||||
})
|
||||
factions.register_command({"claim a", "claim auto"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
factions.claim_auto(player, faction)
|
||||
end
|
||||
})
|
||||
factions.register_command({"claim f", "claim fill"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
factions.claim_fill(player, faction)
|
||||
end
|
||||
})
|
||||
factions.register_command({"claim s", "claim square"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
format = {"string"},
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local arg = args.strings[1]
|
||||
if arg then
|
||||
local r = tonumber(arg)
|
||||
if not r then
|
||||
minetest.chat_send_player(player, "Only use numbers in the second cmd parameter [0-9].")
|
||||
return
|
||||
end
|
||||
factions.claim_square(player, faction, r)
|
||||
else
|
||||
factions.claim_square(player, faction, 3)
|
||||
end
|
||||
end
|
||||
})
|
||||
factions.register_command({"claim c", "claim circle"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
format = {"string"},
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local arg = args.strings[1]
|
||||
if arg then
|
||||
local r = tonumber(arg)
|
||||
if not r then
|
||||
minetest.chat_send_player(player, "Only use numbers in the second cmd parameter [0-9].")
|
||||
return
|
||||
end
|
||||
factions.claim_circle(player, faction, r)
|
||||
else
|
||||
factions.claim_circle(player, faction, 3)
|
||||
end
|
||||
end
|
||||
})
|
||||
factions.register_command("claim all", {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
factions.claim_all(player, faction)
|
||||
end
|
||||
})
|
||||
factions.register_command({"claim l", "claim list"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local aclaims = "All claims:\n"
|
||||
for i in pairs(faction.land) do
|
||||
aclaims = aclaims .. i .. "\n"
|
||||
end
|
||||
minetest.chat_send_player(player, aclaims)
|
||||
end
|
||||
})
|
||||
factions.register_command({"claim h", "claim help"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
factions.claim_help(player, arg_two)
|
||||
end
|
||||
})
|
||||
|
||||
factions.register_command({"unclaim o", "unclaim one"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
return unclaim_helper(player, faction, parcelpos)
|
||||
end
|
||||
})
|
||||
factions.register_command ({"unclaim a", "unclaim auto"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
factions.unclaim_auto(player, faction)
|
||||
end
|
||||
})
|
||||
factions.register_command({"unclaim f", "unclaim fill"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
factions.unclaim_fill(player, faction)
|
||||
end
|
||||
})
|
||||
factions.register_command({"unclaim s", "unclaim square"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
format = {"string"},
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local arg = args.strings[1]
|
||||
if arg then
|
||||
local r = tonumber(arg)
|
||||
if not r then
|
||||
minetest.chat_send_player(player, "Only use numbers in the second cmd parameter [0-9].")
|
||||
return
|
||||
end
|
||||
factions.unclaim_square(player, faction, r)
|
||||
else
|
||||
factions.unclaim_square(player, faction, 3)
|
||||
end
|
||||
end
|
||||
})
|
||||
factions.register_command({"unclaim c", "unclaim circle"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
format = {"string"},
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local arg = args.strings[1]
|
||||
if arg then
|
||||
local r = tonumber(arg)
|
||||
if not r then
|
||||
minetest.chat_send_player(player, "Only use numbers in the second cmd parameter [0-9].")
|
||||
return
|
||||
end
|
||||
factions.unclaim_circle(player, faction, r)
|
||||
else
|
||||
factions.unclaim_circle(player, faction, 3)
|
||||
end
|
||||
end
|
||||
})
|
||||
factions.register_command("unclaim all", {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
factions.unclaim_all(player, faction)
|
||||
end
|
||||
})
|
||||
factions.register_command({"unclaim l", "unclaim list"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local aclaims = "All claims:\n"
|
||||
for i in pairs(faction.land) do
|
||||
aclaims = aclaims .. i .. "\n"
|
||||
end
|
||||
minetest.chat_send_player(player, aclaims)
|
||||
end
|
||||
})
|
||||
factions.register_command({"unclaim h", "unclaim help"}, {
|
||||
faction_permissions = {"claim"},
|
||||
global_privileges = def_global_privileges,
|
||||
dont_show_in_help = true,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
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
|
||||
})
|
@ -22,4 +22,3 @@ factions_config.faction_diplomacy = minetest.settings:get_bool("factions.faction
|
||||
factions_config.spawn_teleport = minetest.settings:get_bool("factions.spawn_teleport") or false
|
||||
factions_config.protection_style = minetest.settings:get("factions.protection_style") or "2d"
|
||||
factions_config.faction_user_priv = minetest.settings:get("factions.faction_user_priv") or false
|
||||
factions_config.database = minetest.settings:get("factions.database") or "mod_storage"
|
||||
|
@ -55,5 +55,3 @@ factions.store_ip (store player ip) bool true
|
||||
# 2d limits how far x and z can go but protection on the y goes up and down far.
|
||||
# 3d limits all three axis.
|
||||
factions.protection_style (Protection style) enum 2d 3d,2d
|
||||
# Set the type of database to use.
|
||||
factions.database (Database) enum mod_storage colddb,mod_storage
|
||||
|
@ -3,27 +3,16 @@
|
||||
factions = {}
|
||||
|
||||
-- database
|
||||
factions.root = {}
|
||||
factions.factions = {}
|
||||
factions.parcels = {}
|
||||
factions.players = {}
|
||||
factions.player_ips = {}
|
||||
|
||||
if factions_config.database == "colddb" then
|
||||
-- Create cold databases.
|
||||
factions.root = colddb.Colddb(minetest.get_worldpath() .. "/factions")
|
||||
factions.factions = factions.root.sub_database("factions")
|
||||
factions.parcels = factions.root.sub_database("parcels")
|
||||
factions.players = factions.root.sub_database("players")
|
||||
factions.player_ips = factions.root.sub_database("ips")
|
||||
elseif factions_config.database == "mod_storage" then
|
||||
dofile (minetest.get_modpath("fac_database") .. "/storagedb.lua")
|
||||
factions.root = storagedb.Storagedb("factions")
|
||||
factions.factions = factions.root.sub_database("factions")
|
||||
factions.parcels = factions.root.sub_database("parcels")
|
||||
factions.players = factions.root.sub_database("players")
|
||||
factions.player_ips = factions.root.sub_database("ips")
|
||||
end
|
||||
dofile(minetest.get_modpath("fac_database") .. "/storagedb.lua")
|
||||
factions.factions = storagedb.Storagedb("factions")
|
||||
factions.parcels = storagedb.Storagedb("parcels")
|
||||
factions.players = storagedb.Storagedb("players")
|
||||
factions.player_ips = storagedb.Storagedb("ips")
|
||||
|
||||
-- Memory only storage.
|
||||
factions.onlineplayers = {}
|
||||
|
@ -1,3 +1,2 @@
|
||||
name = fac_database
|
||||
depends = fac_config
|
||||
optional_depends = colddb
|
||||
|
@ -16,51 +16,31 @@ function storagedb.Storagedb(dir)
|
||||
setmetatable(mem_pool_del, {__mode = "kv"})
|
||||
|
||||
local function storekey(key)
|
||||
local list = minetest.deserialize(storage:get_string(directory))
|
||||
local list = deserializer(storage:get_string(directory))
|
||||
if not list then
|
||||
list = {}
|
||||
list[key] = key
|
||||
else
|
||||
list[key] = key
|
||||
end
|
||||
storage:set_string(directory, minetest.serialize(list))
|
||||
storage:set_string(directory, serializer(list))
|
||||
end
|
||||
local function removekey(key)
|
||||
local list = minetest.deserialize(storage:get_string(directory))
|
||||
local list = deserializer(storage:get_string(directory))
|
||||
if not list then
|
||||
list = {}
|
||||
else
|
||||
list[key] = nil
|
||||
end
|
||||
storage:set_string(directory, minetest.serialize(list))
|
||||
storage:set_string(directory, serializer(list))
|
||||
end
|
||||
local function getkeys()
|
||||
local list = minetest.deserialize(storage:get_string(directory))
|
||||
local list = deserializer(storage:get_string(directory))
|
||||
if not list then
|
||||
list = {}
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
self.get_memory_pool = function()
|
||||
return mem_pool
|
||||
end
|
||||
self.set_memory_pool = function(pool)
|
||||
mem_pool = pool
|
||||
end
|
||||
self.add_to_memory_pool = function(value)
|
||||
if value then
|
||||
add_to_mem_pool = value
|
||||
end
|
||||
return add_to_mem_pool
|
||||
end
|
||||
self.get_serializer = function()
|
||||
return serializer, deserializer
|
||||
end
|
||||
self.set_serializer = function(coder, decoder)
|
||||
serializer = coder
|
||||
deserializer = decoder
|
||||
end
|
||||
local function load_into_mem(name, _table)
|
||||
if add_to_mem_pool then
|
||||
mem_pool[name] = {mem = _table}
|
||||
@ -79,7 +59,7 @@ function storagedb.Storagedb(dir)
|
||||
return false
|
||||
end
|
||||
storekey(name)
|
||||
storage:set_string(string.format("%s/%s", directory, name), minetest.serialize(_table))
|
||||
storage:set_string(string.format("%s/%s", directory, name), serializer(_table))
|
||||
end
|
||||
local function save_key(name)
|
||||
storage:set_string(string.format("%s/%s", directory, name), "")
|
||||
@ -91,6 +71,25 @@ function storagedb.Storagedb(dir)
|
||||
end
|
||||
return false
|
||||
end
|
||||
self.get_memory_pool = function()
|
||||
return mem_pool
|
||||
end
|
||||
self.set_memory_pool = function(pool)
|
||||
mem_pool = pool
|
||||
end
|
||||
self.add_to_memory_pool = function(value)
|
||||
if value then
|
||||
add_to_mem_pool = value
|
||||
end
|
||||
return add_to_mem_pool
|
||||
end
|
||||
self.get_serializer = function()
|
||||
return serializer, deserializer
|
||||
end
|
||||
self.set_serializer = function(coder, decoder)
|
||||
serializer = coder
|
||||
deserializer = decoder
|
||||
end
|
||||
self.set_mem = function(name, _table)
|
||||
load_into_mem(name, _table)
|
||||
mem_pool_del[name] = nil
|
||||
|
@ -68,8 +68,9 @@ function factions.on_end_enemy(name, faction)
|
||||
factions.broadcast(name, "This faction is no longer at war with " .. faction .. "!")
|
||||
end
|
||||
function factions.on_set_spawn(name)
|
||||
local faction = factions.factions.get(name)
|
||||
factions.broadcast(name, "The faction spawn has been set to (" .. util.coords3D_string(faction.spawn) .. ").")
|
||||
local faction = factions.factions.get(name)
|
||||
local spawn_str = faction.spawn.x .. ", " .. faction.spawn.y .. ", " .. faction.spawn.z
|
||||
factions.broadcast(name, "The faction spawn has been set to (" .. spawn_str .. ").")
|
||||
end
|
||||
function factions.on_add_rank(name, rank)
|
||||
local faction = factions.factions.get(name)
|
||||
|
Reference in New Issue
Block a user