forked from mtcontrib/factions
Add bulk_save
Wait 5 seconds before saving. Just to take it easy on the harddisk. When the last player leaves it saves instantly.
This commit is contained in:
parent
c47102ca8a
commit
6765f66c6d
@ -530,7 +530,7 @@ if factions_config.faction_diplomacy == true then
|
|||||||
factions.factions[args.strings[1]].request_inbox[faction.name] = "alliance"
|
factions.factions[args.strings[1]].request_inbox[faction.name] = "alliance"
|
||||||
factions.factions[args.strings[1]]:broadcast("An alliance request from faction " .. faction.name .. " has been sent to you.")
|
factions.factions[args.strings[1]]:broadcast("An alliance request from faction " .. faction.name .. " has been sent to you.")
|
||||||
faction:broadcast("An alliance request was sent to faction " .. args.strings[1])
|
faction:broadcast("An alliance request was sent to faction " .. args.strings[1])
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
else
|
else
|
||||||
send_error(player, "You have already sent a request.")
|
send_error(player, "You have already sent a request.")
|
||||||
end
|
end
|
||||||
@ -567,7 +567,7 @@ if factions_config.faction_diplomacy == true then
|
|||||||
factions.factions[args.strings[1]].request_inbox[faction.name] = "neutral"
|
factions.factions[args.strings[1]].request_inbox[faction.name] = "neutral"
|
||||||
factions.factions[args.strings[1]]:broadcast("A neutral request from faction " .. faction.name .. " has been sent to you.")
|
factions.factions[args.strings[1]]:broadcast("A neutral request from faction " .. faction.name .. " has been sent to you.")
|
||||||
faction:broadcast("A neutral request was sent to faction " .. args.strings[1])
|
faction:broadcast("A neutral request was sent to faction " .. args.strings[1])
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
else
|
else
|
||||||
send_error(player, "You have already sent a request.")
|
send_error(player, "You have already sent a request.")
|
||||||
end
|
end
|
||||||
@ -598,7 +598,7 @@ if factions_config.faction_diplomacy == true then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
faction.request_inbox[args.strings[1]] = nil
|
faction.request_inbox[args.strings[1]] = nil
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
else
|
else
|
||||||
send_error(player, "No request was sent to you.")
|
send_error(player, "No request was sent to you.")
|
||||||
end
|
end
|
||||||
@ -619,7 +619,7 @@ if factions_config.faction_diplomacy == true then
|
|||||||
faction.request_inbox[args.strings[1]] = nil
|
faction.request_inbox[args.strings[1]] = nil
|
||||||
factions.factions[args.strings[1]]:broadcast("Faction " .. faction.name .. " refuse to be your ally.")
|
factions.factions[args.strings[1]]:broadcast("Faction " .. faction.name .. " refuse to be your ally.")
|
||||||
faction:broadcast("Refused an request from faction " .. args.strings[1])
|
faction:broadcast("Refused an request from faction " .. args.strings[1])
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
else
|
else
|
||||||
send_error(player, "No request was sent to you.")
|
send_error(player, "No request was sent to you.")
|
||||||
end
|
end
|
||||||
@ -647,7 +647,7 @@ if factions_config.faction_diplomacy == true then
|
|||||||
end
|
end
|
||||||
faction:new_enemy(args.strings[1])
|
faction:new_enemy(args.strings[1])
|
||||||
factions.factions[args.strings[1]]:new_enemy(faction.name)
|
factions.factions[args.strings[1]]:new_enemy(faction.name)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
else
|
else
|
||||||
send_error(player, "You are already at war.")
|
send_error(player, "You are already at war.")
|
||||||
end
|
end
|
||||||
@ -669,7 +669,7 @@ if factions_config.faction_diplomacy == true then
|
|||||||
factions.factions[args.strings[1]]:end_alliance(faction.name)
|
factions.factions[args.strings[1]]:end_alliance(faction.name)
|
||||||
faction:new_neutral(args.strings[1])
|
faction:new_neutral(args.strings[1])
|
||||||
factions.factions[args.strings[1]]:new_neutral(faction.name)
|
factions.factions[args.strings[1]]:new_neutral(faction.name)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
else
|
else
|
||||||
send_error(player, "You where not allies to begin with.")
|
send_error(player, "You where not allies to begin with.")
|
||||||
end
|
end
|
||||||
@ -1230,7 +1230,7 @@ factions.register_command("set_admin", {
|
|||||||
minetest.chat_send_player(player,"faction " .. args.factions[1].name .. " is already an admin faction.")
|
minetest.chat_send_player(player,"faction " .. args.factions[1].name .. " is already an admin faction.")
|
||||||
end
|
end
|
||||||
args.factions[1].is_admin = true
|
args.factions[1].is_admin = true
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
},false)
|
},false)
|
||||||
@ -1247,7 +1247,7 @@ factions.register_command("remove_admin", {
|
|||||||
minetest.chat_send_player(player,"faction " .. args.factions[1].name .. " is not an admin faction to begin with.")
|
minetest.chat_send_player(player,"faction " .. args.factions[1].name .. " is not an admin faction to begin with.")
|
||||||
end
|
end
|
||||||
args.factions[1].is_admin = false
|
args.factions[1].is_admin = false
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
},false)
|
},false)
|
||||||
|
86
factions.lua
86
factions.lua
@ -191,7 +191,7 @@ function factions.new_faction(name,do_not_save)
|
|||||||
f:on_no_parcel()
|
f:on_no_parcel()
|
||||||
end,faction)
|
end,faction)
|
||||||
if not do_not_save then
|
if not do_not_save then
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
return faction
|
return faction
|
||||||
end
|
end
|
||||||
@ -238,7 +238,7 @@ function factions.Faction.set_name(self, name)
|
|||||||
updateFactionName(playername,name)
|
updateFactionName(playername,name)
|
||||||
end
|
end
|
||||||
self:on_set_name(oldname)
|
self:on_set_name(oldname)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.increase_power(self, power)
|
function factions.Faction.increase_power(self, power)
|
||||||
@ -249,7 +249,7 @@ function factions.Faction.increase_power(self, power)
|
|||||||
for i in pairs(self.onlineplayers) do
|
for i in pairs(self.onlineplayers) do
|
||||||
updateHudPower(minetest.get_player_by_name(i),self)
|
updateHudPower(minetest.get_player_by_name(i),self)
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.decrease_power(self, power)
|
function factions.Faction.decrease_power(self, power)
|
||||||
@ -257,7 +257,7 @@ function factions.Faction.decrease_power(self, power)
|
|||||||
for i in pairs(self.onlineplayers) do
|
for i in pairs(self.onlineplayers) do
|
||||||
updateHudPower(minetest.get_player_by_name(i),self)
|
updateHudPower(minetest.get_player_by_name(i),self)
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.increase_maxpower(self, power)
|
function factions.Faction.increase_maxpower(self, power)
|
||||||
@ -265,7 +265,7 @@ function factions.Faction.increase_maxpower(self, power)
|
|||||||
for i in pairs(self.onlineplayers) do
|
for i in pairs(self.onlineplayers) do
|
||||||
updateHudPower(minetest.get_player_by_name(i),self)
|
updateHudPower(minetest.get_player_by_name(i),self)
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.decrease_maxpower(self, power)
|
function factions.Faction.decrease_maxpower(self, power)
|
||||||
@ -356,7 +356,7 @@ function factions.Faction.add_player(self, player, rank)
|
|||||||
self.offlineplayers[player] = 1
|
self.offlineplayers[player] = 1
|
||||||
self.onlineplayers[player] = nil
|
self.onlineplayers[player] = nil
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.check_players_in_faction(self)
|
function factions.Faction.check_players_in_faction(self)
|
||||||
@ -394,7 +394,7 @@ function factions.Faction.remove_player(self, player)
|
|||||||
end
|
end
|
||||||
self.offlineplayers[player] = nil
|
self.offlineplayers[player] = nil
|
||||||
self.onlineplayers[player] = nil
|
self.onlineplayers[player] = nil
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
--! @param parcelpos position of the wanted parcel
|
--! @param parcelpos position of the wanted parcel
|
||||||
@ -428,7 +428,7 @@ function factions.Faction.claim_parcel(self, parcelpos)
|
|||||||
self:increase_usedpower(factions_config.power_per_parcel)
|
self:increase_usedpower(factions_config.power_per_parcel)
|
||||||
self:on_claim_parcel(parcelpos)
|
self:on_claim_parcel(parcelpos)
|
||||||
self:parcelless_check()
|
self:parcelless_check()
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
--! @brief claim a parcel, update power and update global parcels table
|
--! @brief claim a parcel, update power and update global parcels table
|
||||||
@ -439,7 +439,7 @@ function factions.Faction.unclaim_parcel(self, parcelpos)
|
|||||||
self:decrease_usedpower(factions_config.power_per_parcel)
|
self:decrease_usedpower(factions_config.power_per_parcel)
|
||||||
self:on_unclaim_parcel(parcelpos)
|
self:on_unclaim_parcel(parcelpos)
|
||||||
self:parcelless_check()
|
self:parcelless_check()
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.parcelless_check(self)
|
function factions.Faction.parcelless_check(self)
|
||||||
@ -489,7 +489,7 @@ function factions.Faction.disband(self, reason)
|
|||||||
removeHud(i,"powerWatch")
|
removeHud(i,"powerWatch")
|
||||||
end
|
end
|
||||||
factions.factions[self.name] = nil
|
factions.factions[self.name] = nil
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -501,12 +501,12 @@ function factions.Faction.set_leader(self, player)
|
|||||||
self.leader = player
|
self.leader = player
|
||||||
self.players[player] = self.default_leader_rank
|
self.players[player] = self.default_leader_rank
|
||||||
self:on_new_leader()
|
self:on_new_leader()
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.set_message_of_the_day(self,text)
|
function factions.Faction.set_message_of_the_day(self,text)
|
||||||
self.message_of_the_day = text
|
self.message_of_the_day = text
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
--! @brief check permissions for a given player
|
--! @brief check permissions for a given player
|
||||||
@ -526,7 +526,7 @@ function factions.Faction.has_permission(self, player, permission)
|
|||||||
else
|
else
|
||||||
if not self.rankless then
|
if not self.rankless then
|
||||||
self.rankless = true
|
self.rankless = true
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -535,27 +535,27 @@ end
|
|||||||
function factions.Faction.set_description(self, new)
|
function factions.Faction.set_description(self, new)
|
||||||
self.description = new
|
self.description = new
|
||||||
self:on_change_description()
|
self:on_change_description()
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
--! @brief places player in invite list
|
--! @brief places player in invite list
|
||||||
function factions.Faction.invite_player(self, player)
|
function factions.Faction.invite_player(self, player)
|
||||||
self.invited_players[player] = true
|
self.invited_players[player] = true
|
||||||
self:on_player_invited(player)
|
self:on_player_invited(player)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
--! @brief removes player from invite list (can no longer join via /f join)
|
--! @brief removes player from invite list (can no longer join via /f join)
|
||||||
function factions.Faction.revoke_invite(self, player)
|
function factions.Faction.revoke_invite(self, player)
|
||||||
self.invited_players[player] = nil
|
self.invited_players[player] = nil
|
||||||
self:on_revoke_invite(player)
|
self:on_revoke_invite(player)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
--! @brief set faction openness
|
--! @brief set faction openness
|
||||||
function factions.Faction.toggle_join_free(self, bool)
|
function factions.Faction.toggle_join_free(self, bool)
|
||||||
self.join_free = bool
|
self.join_free = bool
|
||||||
self:on_toggle_join_free()
|
self:on_toggle_join_free()
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
--! @return true if a player can use /f join, false otherwise
|
--! @return true if a player can use /f join, false otherwise
|
||||||
@ -572,13 +572,13 @@ function factions.Faction.new_alliance(self, faction)
|
|||||||
if self.neutral[faction] then
|
if self.neutral[faction] then
|
||||||
self:end_neutral(faction)
|
self:end_neutral(faction)
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.end_alliance(self, faction)
|
function factions.Faction.end_alliance(self, faction)
|
||||||
self.allies[faction] = nil
|
self.allies[faction] = nil
|
||||||
self:on_end_alliance(faction)
|
self:on_end_alliance(faction)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.new_neutral(self, faction)
|
function factions.Faction.new_neutral(self, faction)
|
||||||
@ -590,13 +590,13 @@ function factions.Faction.new_neutral(self, faction)
|
|||||||
if self.enemies[faction] then
|
if self.enemies[faction] then
|
||||||
self:end_enemy(faction)
|
self:end_enemy(faction)
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.end_neutral(self, faction)
|
function factions.Faction.end_neutral(self, faction)
|
||||||
self.neutral[faction] = nil
|
self.neutral[faction] = nil
|
||||||
self:on_end_neutral(faction)
|
self:on_end_neutral(faction)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.new_enemy(self, faction)
|
function factions.Faction.new_enemy(self, faction)
|
||||||
@ -608,20 +608,20 @@ function factions.Faction.new_enemy(self, faction)
|
|||||||
if self.neutral[faction] then
|
if self.neutral[faction] then
|
||||||
self:end_neutral(faction)
|
self:end_neutral(faction)
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.end_enemy(self, faction)
|
function factions.Faction.end_enemy(self, faction)
|
||||||
self.enemies[faction] = nil
|
self.enemies[faction] = nil
|
||||||
self:on_end_enemy(faction)
|
self:on_end_enemy(faction)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
--! @brief faction's member will now spawn in a new place
|
--! @brief faction's member will now spawn in a new place
|
||||||
function factions.Faction.set_spawn(self, pos)
|
function factions.Faction.set_spawn(self, pos)
|
||||||
self.spawn = {x=pos.x, y=pos.y, z=pos.z}
|
self.spawn = {x=pos.x, y=pos.y, z=pos.z}
|
||||||
self:on_set_spawn()
|
self:on_set_spawn()
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.tp_spawn(self, playername)
|
function factions.Faction.tp_spawn(self, playername)
|
||||||
@ -637,7 +637,7 @@ end
|
|||||||
function factions.Faction.add_rank(self, rank, perms)
|
function factions.Faction.add_rank(self, rank, perms)
|
||||||
self.ranks[rank] = perms
|
self.ranks[rank] = perms
|
||||||
self:on_add_rank(rank)
|
self:on_add_rank(rank)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
--! @brief replace an rank's permissions
|
--! @brief replace an rank's permissions
|
||||||
@ -646,7 +646,7 @@ end
|
|||||||
function factions.Faction.replace_privs(self, rank, perms)
|
function factions.Faction.replace_privs(self, rank, perms)
|
||||||
self.ranks[rank] = perms
|
self.ranks[rank] = perms
|
||||||
self:on_replace_privs(rank)
|
self:on_replace_privs(rank)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.remove_privs(self, rank, perms)
|
function factions.Faction.remove_privs(self, rank, perms)
|
||||||
@ -664,7 +664,7 @@ function factions.Faction.remove_privs(self, rank, perms)
|
|||||||
else
|
else
|
||||||
self:broadcast("No privilege was revoked from rank "..rank..".")
|
self:broadcast("No privilege was revoked from rank "..rank..".")
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.add_privs(self, rank, perms)
|
function factions.Faction.add_privs(self, rank, perms)
|
||||||
@ -682,7 +682,7 @@ function factions.Faction.add_privs(self, rank, perms)
|
|||||||
else
|
else
|
||||||
self:broadcast("The rank "..rank.." already has these privileges.")
|
self:broadcast("The rank "..rank.." already has these privileges.")
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.set_rank_name(self, oldrank, newrank)
|
function factions.Faction.set_rank_name(self, oldrank, newrank)
|
||||||
@ -703,7 +703,7 @@ function factions.Faction.set_rank_name(self, oldrank, newrank)
|
|||||||
self:broadcast("The default rank given to new players is set to "..newrank)
|
self:broadcast("The default rank given to new players is set to "..newrank)
|
||||||
end
|
end
|
||||||
self:on_set_rank_name(oldrank, newrank)
|
self:on_set_rank_name(oldrank, newrank)
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.set_def_rank(self, rank)
|
function factions.Faction.set_def_rank(self, rank)
|
||||||
@ -715,7 +715,7 @@ function factions.Faction.set_def_rank(self, rank)
|
|||||||
self.default_rank = rank
|
self.default_rank = rank
|
||||||
self:on_set_def_rank(rank)
|
self:on_set_def_rank(rank)
|
||||||
self.rankless = false
|
self.rankless = false
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.reset_ranks(self)
|
function factions.Faction.reset_ranks(self)
|
||||||
@ -731,7 +731,7 @@ function factions.Faction.reset_ranks(self)
|
|||||||
end
|
end
|
||||||
self:on_reset_ranks()
|
self:on_reset_ranks()
|
||||||
self.rankless = false
|
self.rankless = false
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
--! @brief delete a rank and replace it
|
--! @brief delete a rank and replace it
|
||||||
@ -753,7 +753,7 @@ function factions.Faction.delete_rank(self, rank, newrank)
|
|||||||
self.default_rank = newrank
|
self.default_rank = newrank
|
||||||
self:broadcast("The default rank given to new players is set to "..newrank)
|
self:broadcast("The default rank given to new players is set to "..newrank)
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
|
|
||||||
--! @brief set a player's rank
|
--! @brief set a player's rank
|
||||||
@ -799,7 +799,7 @@ function factions.Faction.attack_parcel(self, parcelpos)
|
|||||||
if self.power < 0. then -- punish memers
|
if self.power < 0. then -- punish memers
|
||||||
minetest.chat_send_all("Faction "..self.name.." has attacked too much and has now negative power!")
|
minetest.chat_send_all("Faction "..self.name.." has attacked too much and has now negative power!")
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
else
|
else
|
||||||
self:broadcast("You can not attack that parcel because it belongs to an ally.")
|
self:broadcast("You can not attack that parcel because it belongs to an ally.")
|
||||||
end
|
end
|
||||||
@ -816,7 +816,7 @@ function factions.Faction.stop_attack(self, parcelpos)
|
|||||||
attacked_faction:broadcast("Parcel ("..parcelpos..") is no longer under attack from "..self.name..".")
|
attacked_faction:broadcast("Parcel ("..parcelpos..") is no longer under attack from "..self.name..".")
|
||||||
self:broadcast("Parcel ("..parcelpos..") has been reconquered by "..attacked_faction.name..".")
|
self:broadcast("Parcel ("..parcelpos..") has been reconquered by "..attacked_faction.name..".")
|
||||||
end
|
end
|
||||||
factions.save()
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1037,6 +1037,8 @@ function factions.get_faction_list()
|
|||||||
return retval
|
return retval
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local saving = false
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- name: save()
|
-- name: save()
|
||||||
--
|
--
|
||||||
@ -1060,7 +1062,14 @@ function factions.save()
|
|||||||
minetest.log("error","MOD factions: unable to save factions world specific data!: " .. error)
|
minetest.log("error","MOD factions: unable to save factions world specific data!: " .. error)
|
||||||
end
|
end
|
||||||
factions_ip.save()
|
factions_ip.save()
|
||||||
|
saving = false
|
||||||
|
end
|
||||||
|
|
||||||
|
function factions.bulk_save()
|
||||||
|
if saving == false then
|
||||||
|
saving = true
|
||||||
|
minetest.after(5,function() factions.save() end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@ -1289,8 +1298,11 @@ function factions.faction_tick()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local player_count = 0
|
||||||
|
|
||||||
minetest.register_on_joinplayer(
|
minetest.register_on_joinplayer(
|
||||||
function(player)
|
function(player)
|
||||||
|
player_count = player_count + 1
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
minetest.after(5,createHudfactionLand,player)
|
minetest.after(5,createHudfactionLand,player)
|
||||||
local faction = factions.get_player_faction(name)
|
local faction = factions.get_player_faction(name)
|
||||||
@ -1323,11 +1335,13 @@ function(player)
|
|||||||
minetest.chat_send_player(name,faction.message_of_the_day)
|
minetest.chat_send_player(name,faction.message_of_the_day)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
factions.bulk_save()
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(
|
minetest.register_on_leaveplayer(
|
||||||
function(player)
|
function(player)
|
||||||
|
player_count = player_count - 1
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local faction = factions.get_player_faction(name)
|
local faction = factions.get_player_faction(name)
|
||||||
local id_name1 = name .. "factionLand"
|
local id_name1 = name .. "factionLand"
|
||||||
@ -1345,6 +1359,10 @@ minetest.register_on_leaveplayer(
|
|||||||
end
|
end
|
||||||
faction.offlineplayers[name] = 1
|
faction.offlineplayers[name] = 1
|
||||||
faction.onlineplayers[name] = nil
|
faction.onlineplayers[name] = nil
|
||||||
|
end
|
||||||
|
if player_count > 0 then
|
||||||
|
factions.bulk_save()
|
||||||
|
else
|
||||||
factions.save()
|
factions.save()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -81,7 +81,7 @@ for i,k in ipairs(doors) do
|
|||||||
if minetest.registered_nodes[k] then
|
if minetest.registered_nodes[k] then
|
||||||
local dw = minetest.registered_nodes[k]
|
local dw = minetest.registered_nodes[k]
|
||||||
local def_after_place_node = dw.on_rightclick
|
local def_after_place_node = dw.on_rightclick
|
||||||
local can_dig = dw.can_dig
|
local def_can_dig = dw.can_dig
|
||||||
local clonenode = {}
|
local clonenode = {}
|
||||||
for k,v in pairs(minetest.registered_nodes[k]) do clonenode[k] = v end
|
for k,v in pairs(minetest.registered_nodes[k]) do clonenode[k] = v end
|
||||||
clonenode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
clonenode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
@ -91,7 +91,7 @@ for i,k in ipairs(doors) do
|
|||||||
end
|
end
|
||||||
clonenode.can_dig = function(pos, digger)
|
clonenode.can_dig = function(pos, digger)
|
||||||
if factions.can_use_node(pos, digger:get_player_name(),"door") then
|
if factions.can_use_node(pos, digger:get_player_name(),"door") then
|
||||||
return can_dig(pos, digger)
|
return def_can_dig(pos, digger)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user