Page 1 of 1

Using market

Posted: Fri Feb 28, 2014 3:53 pm
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?

Re: Using market

Posted: Fri Feb 28, 2014 6:56 pm
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

Re: Using market

Posted: Sat Mar 01, 2014 4:51 pm
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: