This commit is contained in:
Coder12a 2018-10-22 14:30:11 -05:00
parent 1fa1cdcb0f
commit d481a8fa7a
3 changed files with 39 additions and 29 deletions

View File

@ -1,21 +1,21 @@
factions_config = {}
local flip = minetest.settings:get("protection_max_depth") or 512
local flip = tonumber(minetest.settings:get("protection_max_depth")) or 512
factions_config.protection_max_depth = -flip
factions_config.protection_max_height = minetest.settings:get("protection_max_height") or 10000
factions_config.power_per_parcel = minetest.settings:get("power_per_parcel") or 0.5
factions_config.power_per_death = minetest.settings:get("power_per_death") or 0.25
factions_config.power_per_tick = minetest.settings:get("power_per_tick") or 0.125
factions_config.tick_time = minetest.settings:get("tick_time") or 60
factions_config.power_per_attack = minetest.settings:get("power_per_attack") or 10
factions_config.faction_name_max_length = minetest.settings:get("faction_name_max_length") or 50
factions_config.rank_name_max_length = minetest.settings:get("rank_name_max_length") or 25
factions_config.maximum_faction_inactivity = minetest.settings:get("maximum_faction_inactivity") or 604800
factions_config.maximum_parcelless_faction_time = minetest.settings:get("maximum_parcelless_faction_time") or 10800
factions_config.power = minetest.settings:get("power") or 0
factions_config.maxpower = minetest.settings:get("maxpower") or 0
factions_config.power_per_player = minetest.settings:get("power_per_player") or 0.125
factions_config.powermax_per_player = minetest.settings:get("powermax_per_player") or 2
factions_config.parcel_size = minetest.settings:get("parcel_size") or 16
factions_config.protection_max_height = tonumber(minetest.settings:get("protection_max_height")) or 10000
factions_config.power_per_parcel = tonumber(minetest.settings:get("power_per_parcel")) or 0.5
factions_config.power_per_death = tonumber(minetest.settings:get("power_per_death")) or 0.25
factions_config.power_per_tick = tonumber(minetest.settings:get("power_per_tick")) or 0.125
factions_config.tick_time = tonumber(minetest.settings:get("tick_time")) or 60
factions_config.power_per_attack = tonumber(minetest.settings:get("power_per_attack")) or 10
factions_config.faction_name_max_length = tonumber(minetest.settings:get("faction_name_max_length")) or 50
factions_config.rank_name_max_length = tonumber(minetest.settings:get("rank_name_max_length")) or 25
factions_config.maximum_faction_inactivity = tonumber(minetest.settings:get("maximum_faction_inactivity")) or 604800
factions_config.maximum_parcelless_faction_time = tonumber(minetest.settings:get("maximum_parcelless_faction_time")) or 10800
factions_config.power = tonumber(minetest.settings:get("power")) or 0
factions_config.maxpower = tonumber(minetest.settings:get("maxpower")) or 0
factions_config.power_per_player = tonumber(minetest.settings:get("power_per_player")) or 0.125
factions_config.powermax_per_player = tonumber(minetest.settings:get("powermax_per_player")) or 2
factions_config.parcel_size = tonumber(minetest.settings:get("parcel_size")) or 16
factions_config.protection_depth_height_limit = minetest.settings:get_bool("protection_depth_height_limit") or true
factions_config.enable_power_per_player = minetest.settings:get_bool("power_per_playerb") or true
factions_config.attack_parcel = minetest.settings:get_bool("attack_parcel") or false

View File

@ -207,9 +207,8 @@ function factions.Faction.add_player(self, player, rank)
end
end
if notsame then
self:increase_power(factions_config.power_per_player)
self:increase_maxpower(factions_config.powermax_per_player)
self:decrease_usedpower(factions_config.power_per_player)
self:increase_power(factions_config.power_per_player)
end
end
local pdata = minetest.get_player_by_name(player)
@ -328,7 +327,6 @@ end
--! @brief disband faction, updates global players and parcels table
function factions.Faction.disband(self, reason)
local playerslist = minetest.get_connected_players()
for i,v in pairs(factions.factions) do
if v.name ~= self.name then
if v.enemies[self.name] then
@ -349,15 +347,13 @@ function factions.Faction.disband(self, reason)
factions.parcels[k] = nil
end
self:on_disband(reason)
local playerslist = self.onlineplayers
for i,l in pairs(playerslist) do
local faction = factions.get_player_faction(i)
removeHud(i,"factionName")
removeHud(i,"powerWatch")
end
factions.factions[self.name] = nil
for i in pairs(playerslist) do
local realplayer = playerslist[i]
local faction = factions.get_player_faction(realplayer:get_player_name())
if not faction then
removeHud(realplayer,"factionName")
removeHud(realplayer,"powerWatch")
end
end
factions.save()
end
@ -387,6 +383,7 @@ function factions.Faction.has_permission(self, player, permission)
end
return false
end
function factions.Faction.set_description(self, new)
self.description = new
self:on_change_description()
@ -429,11 +426,13 @@ function factions.Faction.new_alliance(self, faction)
end
factions.save()
end
function factions.Faction.end_alliance(self, faction)
self.allies[faction] = nil
self:on_end_alliance(faction)
factions.save()
end
function factions.Faction.new_neutral(self, faction)
self.neutral[faction] = true
self:on_new_neutral(faction)
@ -445,11 +444,13 @@ function factions.Faction.new_neutral(self, faction)
end
factions.save()
end
function factions.Faction.end_neutral(self, faction)
self.neutral[faction] = nil
self:on_end_neutral(faction)
factions.save()
end
function factions.Faction.new_enemy(self, faction)
self.enemies[faction] = true
self:on_new_enemy(faction)
@ -461,6 +462,7 @@ function factions.Faction.new_enemy(self, faction)
end
factions.save()
end
function factions.Faction.end_enemy(self, faction)
self.enemies[faction] = nil
self:on_end_enemy(faction)

12
hud.lua
View File

@ -56,10 +56,18 @@ function updateHudPower(player,faction)
end
function removeHud(player,hudname)
local name = player:get_player_name()
local name = ""
local p = {}
if type(player) ~= "string" then
name = player:get_player_name()
p = player
else
name = player
p = minetest.get_player_by_name(player)
end
local id_name = name .. hudname
if hud_ids[id_name] then
player:hud_remove(hud_ids[id_name])
p:hud_remove(hud_ids[id_name])
hud_ids[id_name] = nil
end
end