mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-14 10:13:13 +02:00
fixed not inserting fish bug
This commit is contained in:
parent
85de06e218
commit
9f77ade128
@ -106,13 +106,22 @@ local total_fish_market_bonus_messages = #fish_market_bonus_message
|
|||||||
|
|
||||||
local function fish_earned(event, amount)
|
local function fish_earned(event, amount)
|
||||||
local player_index = event.player_index
|
local player_index = event.player_index
|
||||||
|
local player = game.players[player_index]
|
||||||
|
|
||||||
|
local stack = {name = 'raw-fish', count = amount}
|
||||||
|
local inserted = player.insert(stack)
|
||||||
|
|
||||||
|
local diff = amount - inserted
|
||||||
|
if diff > 0 then
|
||||||
|
stack.count = diff
|
||||||
|
player.surface.spill_item_stack(player.position, stack, true)
|
||||||
|
end
|
||||||
|
|
||||||
local fish = PlayerStats.get_fish_earned(player_index)
|
local fish = PlayerStats.get_fish_earned(player_index)
|
||||||
fish = fish + amount
|
fish = fish + amount
|
||||||
PlayerStats.set_fish_earned(player_index, fish)
|
PlayerStats.set_fish_earned(player_index, fish)
|
||||||
|
|
||||||
if fish % 70 == 0 then
|
if fish % 70 == 0 then
|
||||||
local player = game.players[player_index]
|
|
||||||
if player and player.valid then
|
if player and player.valid then
|
||||||
local message = fish_market_bonus_message[math.random(total_fish_market_bonus_messages)]
|
local message = fish_market_bonus_message[math.random(total_fish_market_bonus_messages)]
|
||||||
player.print(message)
|
player.print(message)
|
||||||
|
Loading…
Reference in New Issue
Block a user