If a market offer is made and has two of the same items (perhaps more), the result is the second item amount is shown (and is the amount taken) but the "minimum" amount to purchase and quantity of purchases is based on the first item price. If the "minimum" is not met, the offer cannot be purchased, even when the gui is showing a different amount.
/c
local player = game.player
local surface = player.surface
local position = player.position
local market_position = surface.find_non_colliding_position("market", position, 10, 1, true)
if market_position then
local market = surface.create_entity{name = "market", position = market_position, force = "player"}
if market then
local offer = {
price = {
{amount = 25, name = "iron-ore", type = "item"},
{amount = 5, name = "iron-ore", type = "item"},
},
offer = {
type = "give-item",
item = "copper-ore",
count = 10,
}
}
market.add_market_item(offer)
else
game.print("could not create market")
end
else
game.print("no position found to create market")
end
result_with_50_ore.png (89.37 KiB) Viewed 3109 times
The api pages don't say what is expected for an offer used in add_market_item, but if it is a list of ingredients, then there could be different expectations... 1) error on repeated items (as ingredients do in prototypes) or 2) collapse items into one quantity (if a fluid with temperature can be a market price, this would not work).
Re: [1.1.30] market price bug with repeated element
Posted: Tue Apr 13, 2021 10:05 pm
by boskid
Thanks for the report. It is a minor issue but i fixed it anyway for 1.1.32.