mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
Fixed saved prices being synced between forces
This commit is contained in:
parent
5143a12d15
commit
2a83ea5ad1
@ -17,12 +17,16 @@ local unlock_progress = {
|
||||
}
|
||||
}
|
||||
|
||||
local saved_prices = {}
|
||||
|
||||
Global.register(
|
||||
{
|
||||
unlock_progress = unlock_progress
|
||||
unlock_progress = unlock_progress,
|
||||
saved_prices = saved_prices
|
||||
},
|
||||
function(tbl)
|
||||
unlock_progress = tbl.unlock_progress
|
||||
saved_prices = tbl.saved_prices
|
||||
end
|
||||
)
|
||||
|
||||
@ -82,12 +86,7 @@ local function random_tech(tier, force, group_name)
|
||||
if not techs_left then
|
||||
local items = Retailer.get_items(group_name)
|
||||
local price = items[tier_name].price
|
||||
for _, prototype in pairs(MarketItems) do
|
||||
if prototype.name == tier_name then
|
||||
prototype.price = price
|
||||
break
|
||||
end
|
||||
end
|
||||
saved_prices[force.name][tier_name] = price
|
||||
Retailer.remove_item(group_name, tier_name)
|
||||
end
|
||||
end
|
||||
@ -124,6 +123,7 @@ local function on_market_purchase(event)
|
||||
if not Retailer.get_items(group_name)[tier_name] then
|
||||
for _, prototype in pairs(MarketItems) do
|
||||
if prototype.name == tier_name then
|
||||
prototype.price = saved_prices[force.name][tier_name]
|
||||
Retailer.set_item(group_name, prototype)
|
||||
break
|
||||
end
|
||||
|
@ -148,7 +148,7 @@ Event.on_init(
|
||||
local items = Table.deep_copy(Market_Items)
|
||||
for _, prototype in pairs(items) do
|
||||
local name = prototype.name
|
||||
prototype.price = (disabled_research[name] and disabled_research[name].player) and disabled_research[name].player * player_kill_reward or prototype.price
|
||||
--prototype.price = (disabled_research[name] and disabled_research[name].player) and disabled_research[name].player * player_kill_reward or prototype.price
|
||||
local unlock_requires = disabled_research[name]
|
||||
if prototype.disabled and unlock_requires then
|
||||
if unlock_requires.invert then
|
||||
@ -161,18 +161,6 @@ Event.on_init(
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Items support the following structure:
|
||||
{
|
||||
name: the (raw) item inserted in inventory, does nothing when type is not item
|
||||
name_label: the name shown in the GUI. If omitted and a prototype exists for 'name', it will use that LocalisedString, can be a LocalisedString
|
||||
sprite: a custom sprite, will use 'item/<name>' if omitted
|
||||
price: the price of an item, supports floats (0.95 for example)
|
||||
description: an additional description displayed in the tooltip, can be a LocalisedString
|
||||
disabled: whether or not the item should be disabled by default
|
||||
disabled_reason: the reason the item is disabled, can be a LocalisedString
|
||||
}
|
||||
]]
|
||||
--ensures that the spawn points are not water
|
||||
surface.set_tiles(
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user