Merge pull request #31 from shamoanjac/master

fixes and addons
This commit is contained in:
agrecascino 2016-08-27 18:11:28 -04:00 committed by GitHub
commit 468ef6c394
2 changed files with 52 additions and 2 deletions

View File

@ -557,6 +557,52 @@ factions.register_command("forceupdate", {
end
})
factions.register_command("which", {
description = "Gets a player's faction",
infaction = false,
format = {"string"},
on_success = function(player, faction, pos, parcelpos, args)
local playername = args.strings[1]
local faction = factions.get_player_faction(playername)
if not faction then
send_error(player, "Player "..playername.." does not belong to any faction")
return false
else
minetest.chat_send_player(player, "player "..playername.." belongs to faction "..faction.name)
return true
end
end
})
factions.register_command("setleader", {
description = "Set a player as a faction's leader",
infaction = false,
global_privileges = {"faction_admin"},
format = {"faction", "player"},
on_success = function(player, faction, pos, parcelpos, args)
local playername = args.players[1]:get_player_name()
local playerfaction = factions.get_player_faction(playername)
local targetfaction = args.factions[1]
if playerfaction.name ~= targetfaction.name then
send_error(player, "Player "..playername.." is not in faction "..targetfaction.name..".")
return false
end
targetfaction:set_leader(playername)
return true
end
})
factions.register_command("setadmin", {
description = "Make a faction an admin faction",
infaction = false,
global_privileges = {"faction_admin"},
format = {"faction"},
on_success = function(player, faction, pos, parcelpos, args)
args.factions[1].is_admin = false
return true
end
})
-------------------------------------------------------------------------------
-- name: cmdhandler(playername,parameter)
--

View File

@ -248,6 +248,9 @@ end
--! @brief change the faction leader
function factions.Faction.set_leader(self, player)
if self.leader then
self.players[self.leader] = self.default_rank
end
self.leader = player
self.players[player] = self.default_leader_rank
self:on_new_leader()
@ -392,7 +395,7 @@ function factions.Faction.is_online(self)
end
function factions.Faction.attack_parcel(self, parcelpos)
local attacked_faction = factions.get_parcel_faction(parcelpos)
--[[ local attacked_faction = factions.get_parcel_faction(parcelpos)
if attacked_faction then
self.power = self.power - factions.power_per_attack
if attacked_faction.attacked_parcels[parcelpos] then
@ -406,6 +409,7 @@ function factions.Faction.attack_parcel(self, parcelpos)
end
factions.save()
end
]]
end
function factions.Faction.stop_attack(self, parcelpos)
@ -710,7 +714,7 @@ factions.faction_tick = function()
if faction:is_online() then
faction:increase_power(factions.power_per_tick)
end
if faction.last_logon - now > factions.maximum_faction_inactivity then
if now - faction.last_logon > factions.maximum_faction_inactivity then
faction:disband()
end
end