mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-16 02:47:48 +02:00
Cleanup member limits
This commit is contained in:
parent
28d6849f1b
commit
ce11951c8a
@ -73,16 +73,13 @@ local function min_slots(slots)
|
||||
return min
|
||||
end
|
||||
|
||||
local function can_force_accept_member(force)
|
||||
local function update_member_limit(force)
|
||||
if not force or not force.valid then
|
||||
log('force nil or not valid!')
|
||||
return
|
||||
end
|
||||
local this = ScenarioTable.get_table()
|
||||
local town_centers = this.town_centers
|
||||
if this.member_limit == nil then
|
||||
this.member_limit = 1
|
||||
end
|
||||
|
||||
-- get the members of each force name into a table
|
||||
local slots = {0, 0, 0}
|
||||
@ -101,11 +98,19 @@ local function can_force_accept_member(force)
|
||||
end
|
||||
end
|
||||
-- get the min of all slots
|
||||
local member_limit = min_slots(slots) + 1
|
||||
this.member_limit = member_limit
|
||||
this.member_limit = min_slots(slots) + 1
|
||||
end
|
||||
|
||||
if #force.connected_players >= member_limit then
|
||||
game.print('>> Town ' .. force.name .. ' has too many settlers! Current limit (' .. member_limit .. ')', {255, 255, 0})
|
||||
local function can_force_accept_member(force)
|
||||
if not force or not force.valid then
|
||||
log('force nil or not valid!')
|
||||
return
|
||||
end
|
||||
local this = ScenarioTable.get_table()
|
||||
update_member_limit(force)
|
||||
|
||||
if #force.players >= this.member_limit then
|
||||
game.print('>> Town ' .. force.name .. ' has too many settlers! Current limit (' .. this.member_limit .. ')', {255, 255, 0})
|
||||
return false
|
||||
end
|
||||
return true
|
||||
@ -234,6 +239,9 @@ function Public.add_player_to_town(player, town_center)
|
||||
player.tag = ''
|
||||
Map.enable_world_map(player)
|
||||
Public.set_player_color(player)
|
||||
|
||||
update_member_limit(force)
|
||||
game.print('>> The new member limit for all towns is now: (' .. this.member_limit .. ')', {255, 255, 0})
|
||||
end
|
||||
|
||||
-- given to player upon respawn
|
||||
|
@ -5,6 +5,7 @@ local table_insert = table.insert
|
||||
local math_floor = math.floor
|
||||
local math_sqrt = math.sqrt
|
||||
local table_shuffle = table.shuffle_table
|
||||
local table_size = table.size
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
@ -305,9 +306,7 @@ local function is_valid_location(force_name, surface, position)
|
||||
end
|
||||
end
|
||||
|
||||
local town_count = 0
|
||||
for _ in pairs(this.town_centers) do town_count = town_count + 1 end
|
||||
if town_count > 48 then
|
||||
if table_size(this.town_centers) > 48 then
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
|
@ -10,7 +10,7 @@ local function can_force_accept_member(force)
|
||||
local townytable = Table.get_table()
|
||||
local town_centers = townytable.town_centers
|
||||
local size_of_town_centers = townytable.size_of_town_centers
|
||||
local member_limit = 3
|
||||
local member_limit = 0
|
||||
|
||||
if size_of_town_centers <= 1 then
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user