From a8865205e8b9f4c8b9c035dc7226460630c1dc78 Mon Sep 17 00:00:00 2001 From: Valansch Date: Sat, 2 Sep 2017 14:58:18 +0200 Subject: [PATCH] Fixed exception in on_tick after well was removed. #44 --- control.lua | 3 ++- on_tick.lua | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/control.lua b/control.lua index c1a55cca..874b6df2 100644 --- a/control.lua +++ b/control.lua @@ -2,6 +2,7 @@ require "util" require "locale/utils/event" require "config" require "locale/utils/utils" +require "locale/utils/list_utils" require "base_data" require "user_groups" require "chatlog" @@ -41,4 +42,4 @@ function walkabout(player_name, distance) game.player.print("This command moved to /walkabout.") end -Event.register(defines.events.on_player_created, player_joined) \ No newline at end of file +Event.register(defines.events.on_player_created, player_joined) diff --git a/on_tick.lua b/on_tick.lua index e9bab9c8..387261b2 100644 --- a/on_tick.lua +++ b/on_tick.lua @@ -1,6 +1,10 @@ function refill_well() - for _,well in pairs(global.wells) do - well.chest.insert({name = well.item, count = well.items_per_second * 15}) + for _,well in pairs(global.wells) do + if well.chest.valid then + well.chest.insert({name = well.item, count = well.items_per_second * 15}) + else + table.remove_element(global.wells, well) + end end end