Factorio: Fix free samples still preventing starting items
This commit is contained in:
parent
4efd27694a
commit
382c6d0445
|
@ -35,9 +35,7 @@ function on_player_created(event)
|
||||||
-- FIXME: This (probably) fires before any other mod has a chance to change the player's force
|
-- FIXME: This (probably) fires before any other mod has a chance to change the player's force
|
||||||
-- For now, they will (probably) always be on the 'player' force when this event fires.
|
-- For now, they will (probably) always be on the 'player' force when this event fires.
|
||||||
local data = {}
|
local data = {}
|
||||||
if FREE_SAMPLES ~= 0 then
|
|
||||||
data['pending_samples'] = table.deepcopy(global.forcedata[player.force.name]['earned_samples'])
|
data['pending_samples'] = table.deepcopy(global.forcedata[player.force.name]['earned_samples'])
|
||||||
end
|
|
||||||
global.playerdata[player.index] = data
|
global.playerdata[player.index] = data
|
||||||
update_player(player.index) -- Attempt to send pending free samples, if relevant.
|
update_player(player.index) -- Attempt to send pending free samples, if relevant.
|
||||||
end
|
end
|
||||||
|
@ -56,9 +54,6 @@ script.on_event(defines.events.on_rocket_launched, on_rocket_launched)
|
||||||
|
|
||||||
-- Updates a player, attempting to send them any pending samples (if relevant)
|
-- Updates a player, attempting to send them any pending samples (if relevant)
|
||||||
function update_player(index)
|
function update_player(index)
|
||||||
if FREE_SAMPLES == 0 then -- This is effectively a noop
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local player = game.players[index]
|
local player = game.players[index]
|
||||||
if not player or not player.valid then -- Do nothing if we reference an invalid player somehow
|
if not player or not player.valid then -- Do nothing if we reference an invalid player somehow
|
||||||
return
|
return
|
||||||
|
@ -108,9 +103,7 @@ function update_player_event(event)
|
||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
|
|
||||||
if FREE_SAMPLES then
|
script.on_event(defines.events.on_player_main_inventory_changed, update_player_event)
|
||||||
script.on_event(defines.events.on_player_main_inventory_changed, update_player_event)
|
|
||||||
end
|
|
||||||
|
|
||||||
function add_samples(force, name, count)
|
function add_samples(force, name, count)
|
||||||
local function add_to_table(t)
|
local function add_to_table(t)
|
||||||
|
|
Loading…
Reference in New Issue