1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-05 15:05:57 +02:00

Move level up logic outside of unlock check loop

This commit is contained in:
damium 2018-11-17 11:07:20 -08:00 committed by GitHub
parent bbd201d2d0
commit af8b2b6bc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,20 +122,15 @@ local function update_market_contents(market)
local old_level = stone_tracker.current_level
local print = game.print
if (calculate_level(stone_tracker.current_level+1) <= stone_tracker.stone_sent_to_surface) then
stone_tracker.current_level = stone_tracker.current_level + 1
end
for _, unlockable in pairs(config.unlockables) do
local stone_unlock = calculate_level(unlockable.level)
local is_in_range = stone_unlock > stone_tracker.previous_stone_sent_to_surface and stone_unlock <= stone_tracker.stone_sent_to_surface
if (stone_tracker.current_level == old_level) then
while (calculate_level(stone_tracker.current_level) < stone_tracker.stone_sent_to_surface) do
if (calculate_level(stone_tracker.current_level+1) <= stone_tracker.stone_sent_to_surface) then
stone_tracker.current_level = stone_tracker.current_level + 1
else
break
end
end
end
-- only add the item to the market if it's between the old and new stone range
if (is_in_range and unlockable.type == 'market') then
add_market_item = add_market_item or market.add_market_item