Using market

This subforum contains all the issues which we already resolved.
User avatar
Reygan
Fast Inserter
Fast Inserter
Posts: 177
Joined: Tue Jan 28, 2014 8:42 pm
Contact:

Using market

Post by Reygan »

control.lua :

Code: Select all

game.oninit(function()
	local market=game.getentitybytag("market")
	market.addmarketitem({price={"iron-ore", 10}, offer={type="give-item", item="copper-ore"}}) --Adds market offer, 1 copper ore for 10 iron ore.
	market.addmarketitem({price={"coin", 10}, offer={type="give-item", item="iron-plate"}})
end)
When i am trying to create new game with my scenario i have notice window "Error while running the oninit: ...|control.lua:3: No such node (name)".
Am i did something wrong? What is mysterious node "name"?
This example (3rd string) is from factorio wiki, so why it doesnt work? In "Tight spot" campaign is same syntax, but this campaign wont work as on 0.9.1, as on 0.8.8 :)
Is this a incompatibility, and only way to use market is version 0.7.5, as noted in scenario pack? Or where i can find description of new syntax?
Daniel V. Lenskiy
kovarex
Factorio Staff
Factorio Staff
Posts: 8298
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Using market

Post by kovarex »

Hello, the problem is, that the price can contain more than one items, so the correct command is:

Code: Select all

addmarketitem({price={{"iron-ore", 10}}, offer={type="give-item", item="copper-ore"}})
I have to admit, that the example on the wiki was wrong, so I fixed it.
https://forums.factorio.com/wiki/inde ... Lua/Market
User avatar
Reygan
Fast Inserter
Fast Inserter
Posts: 177
Joined: Tue Jan 28, 2014 8:42 pm
Contact:

Re: Using market

Post by Reygan »

kovarex wrote:Hello, the problem is, that the price can contain more than one items, so the correct command is:

Code: Select all

addmarketitem({price={{"iron-ore", 10}}, offer={type="give-item", item="copper-ore"}})
I have to admit, that the example on the wiki was wrong, so I fixed it.
https://forums.factorio.com/wiki/inde ... Lua/Market
Thank you very much! You saved me from long time messing with this crappy brackets :mrgreen:
Daniel V. Lenskiy
Post Reply

Return to “Resolved Problems and Bugs”