Skip to content

Commit ad5268e

Browse files
committed
do first limit check after counting just eggs in case there is no need to count live animals, it should improve performance in one edge case
1 parent be7db59 commit ad5268e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

eggwatch.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,15 @@ local function handle_eggs(eggs)
215215
local current_eggs = eggs.stack_size
216216

217217
local total_count = current_eggs
218-
total_count = total_count + count_forbidden_eggs_for_race_in_claimed_nestobxes(race_creature_id) + count_live_animals(race_creature_id)
218+
total_count = total_count + count_forbidden_eggs_for_race_in_claimed_nestobxes(race_creature_id)
219+
220+
if total_count - current_eggs < max_eggs then
221+
print_detalis(("Total count for %s only existing eggs is %s, about to count life animals if enabled"):format(race_creature_id, total_count - current_eggs))
222+
total_count = total_count + count_live_animals(race_creature_id)
223+
else
224+
print_detalis(("Total count for %s eggs only is %s greater than maximum %s, no need to count life animals"):format(race_creature_id, total_count, max_eggs))
225+
return
226+
end
219227

220228
print_detalis(("Total count for %s eggs is %s"):format(race_creature_id, total_count))
221229

0 commit comments

Comments
 (0)