Fixed player_faction being used instead of faction

This commit is contained in:
shamoanjac 2016-08-14 15:43:53 +02:00
parent 4c3e5025d6
commit a38c82a4e7
2 changed files with 24 additions and 3 deletions

View File

@ -290,8 +290,8 @@ factions.register_command("join", {
on_success = function(player, faction, pos, chunkpos, args) on_success = function(player, faction, pos, chunkpos, args)
local new_faction = args.factions[1] local new_faction = args.factions[1]
if new_faction:can_join(player) then if new_faction:can_join(player) then
if player_faction then -- leave old faction if faction then -- leave old faction
player_faction:remove_player(player) faction:remove_player(player)
end end
new_faction:add_player(player) new_faction:add_player(player)
else else
@ -562,7 +562,7 @@ factions_chat.cmdhandler = function (playername,parameter)
local player = minetest.env:get_player_by_name(playername) local player = minetest.env:get_player_by_name(playername)
local params = parameter:split(" ") local params = parameter:split(" ")
local player_faction = factions.players[playersname] local player_faction = factions.players[playername]
if parameter == nil or if parameter == nil or
parameter == "" then parameter == "" then

View File

@ -171,6 +171,7 @@ function factions.Faction.claim_chunk(self, chunkpos)
self:on_claim_chunk(chunkpos) self:on_claim_chunk(chunkpos)
factions.save() factions.save()
end end
--! @brief claim a chunk, update power and update global chunks table --! @brief claim a chunk, update power and update global chunks table
function factions.Faction.unclaim_chunk(self, chunkpos) function factions.Faction.unclaim_chunk(self, chunkpos)
factions.chunks[chunkpos] = nil factions.chunks[chunkpos] = nil
@ -303,16 +304,19 @@ function factions.Faction.delete_rank(self, rank, newrank)
self:on_delete_rank(rank, newrank) self:on_delete_rank(rank, newrank)
factions.save() factions.save()
end end
--! @param newbanner texture string of the new banner --! @param newbanner texture string of the new banner
function factions.Faction.set_banner(self, newbanner) function factions.Faction.set_banner(self, newbanner)
self.banner = newbanner self.banner = newbanner
self:on_new_banner() self:on_new_banner()
end end
--! @brief set a player's rank --! @brief set a player's rank
function factions.Faction.promote(self, member, rank) function factions.Faction.promote(self, member, rank)
self.players[member] = rank self.players[member] = rank
self:on_promote(member) self:on_promote(member)
end end
--! @brief send a message to all members --! @brief send a message to all members
function factions.Faction.broadcast(self, msg, sender) function factions.Faction.broadcast(self, msg, sender)
local message = self.name.."> "..msg local message = self.name.."> "..msg
@ -330,54 +334,71 @@ end
function factions.Faction.on_create(self) --! @brief called when the faction is added to the global faction list function factions.Faction.on_create(self) --! @brief called when the faction is added to the global faction list
minetest.chat_send_all("Faction "..self.name.." has been created.") minetest.chat_send_all("Faction "..self.name.." has been created.")
end end
function factions.Faction.on_player_leave(self, player) function factions.Faction.on_player_leave(self, player)
self:broadcast(player.." has left this faction.") self:broadcast(player.." has left this faction.")
end end
function factions.Faction.on_player_join(self, player) function factions.Faction.on_player_join(self, player)
self:broadcast(player.." has joined this faction.") self:broadcast(player.." has joined this faction.")
end end
function factions.Faction.on_claim_chunk(self, pos) function factions.Faction.on_claim_chunk(self, pos)
self:broadcast("Chunk ("..pos..") has been claimed.") self:broadcast("Chunk ("..pos..") has been claimed.")
end end
function factions.Faction.on_unclaim_chunk(self, pos) function factions.Faction.on_unclaim_chunk(self, pos)
self:broadcast("Chunk ("..pos..") has been unclaimed.") self:broadcast("Chunk ("..pos..") has been unclaimed.")
end end
function factions.Faction.on_disband(self, pos) function factions.Faction.on_disband(self, pos)
minetest.chat_send_all("Faction "..self.name.." has been disbanded.") minetest.chat_send_all("Faction "..self.name.." has been disbanded.")
end end
function factions.Faction.on_new_leader(self) function factions.Faction.on_new_leader(self)
self:broadcast(self.leader.." is now the leader of this faction.") self:broadcast(self.leader.." is now the leader of this faction.")
end end
function factions.Faction.on_change_description(self) function factions.Faction.on_change_description(self)
self:broadcast("Faction description has been modified to: "..self.description) self:broadcast("Faction description has been modified to: "..self.description)
end end
function factions.Faction.on_player_invited(self, player) function factions.Faction.on_player_invited(self, player)
minetest.chat_send_player(player, "You have been invited to faction "..self.name) minetest.chat_send_player(player, "You have been invited to faction "..self.name)
end end
function factions.Faction.on_toggle_join_free(self, player) function factions.Faction.on_toggle_join_free(self, player)
self:broadcast("This faction is now invite-free.") self:broadcast("This faction is now invite-free.")
end end
function factions.Faction.on_new_alliance(self, faction) function factions.Faction.on_new_alliance(self, faction)
self:broadcast("This faction is now allied with "..faction) self:broadcast("This faction is now allied with "..faction)
end end
function factions.Faction.on_end_alliance(self, faction) function factions.Faction.on_end_alliance(self, faction)
self:broadcast("This faction is no longer allied with "..faction.."!") self:broadcast("This faction is no longer allied with "..faction.."!")
end end
function factions.Faction.on_set_spawn(self) function factions.Faction.on_set_spawn(self)
self:broadcast("The faction spawn has been set to ("..util.coords3D_string(pos)..").") self:broadcast("The faction spawn has been set to ("..util.coords3D_string(pos)..").")
end end
function factions.Faction.on_add_rank(self, rank) function factions.Faction.on_add_rank(self, rank)
self:broadcast("The rank "..rank.." has been created with privileges: "..table.concat(self.ranks[rank], ", ")) self:broadcast("The rank "..rank.." has been created with privileges: "..table.concat(self.ranks[rank], ", "))
end end
function factions.Faction.on_delete_rank(self, rank, newrank) function factions.Faction.on_delete_rank(self, rank, newrank)
self:broadcast("The rank "..rank.." has been deleted and replaced by "..newrank) self:broadcast("The rank "..rank.." has been deleted and replaced by "..newrank)
end end
function factions.Faction.on_new_banner(self) function factions.Faction.on_new_banner(self)
self:broadcast("A new banner has been set.") self:broadcast("A new banner has been set.")
end end
function factions.Faction.on_promote(self, member) function factions.Faction.on_promote(self, member)
minetest.chat_send_player(player, "You have been promoted to "..self.players[member]) minetest.chat_send_player(player, "You have been promoted to "..self.players[member])
end end
function factions.Faction.on_revoke_invite(self, player) function factions.Faction.on_revoke_invite(self, player)
minetest.chat_send_player(player, "You are no longer invited to faction "..self.name) minetest.chat_send_player(player, "You are no longer invited to faction "..self.name)
end end