From 9f77ade128d2c8298f259188d32ad3acbdb9acad Mon Sep 17 00:00:00 2001 From: grilledham Date: Sun, 1 Jul 2018 14:06:02 +0100 Subject: [PATCH] fixed not inserting fish bug --- fish_market.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fish_market.lua b/fish_market.lua index b4d67515..54d36acd 100644 --- a/fish_market.lua +++ b/fish_market.lua @@ -106,13 +106,22 @@ local total_fish_market_bonus_messages = #fish_market_bonus_message local function fish_earned(event, amount) 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) fish = fish + amount PlayerStats.set_fish_earned(player_index, fish) if fish % 70 == 0 then - local player = game.players[player_index] if player and player.valid then local message = fish_market_bonus_message[math.random(total_fish_market_bonus_messages)] player.print(message)