How to make a working market?

Place to share custom user maps, scenarios and campaigns.
Post Reply
TheNarwhal
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Nov 19, 2014 7:34 pm
Contact:

How to make a working market?

Post by TheNarwhal »

So I made a post in the Multiplayer forums asking about how markets work. Didn't get anything from that, BUT I did find the answer to my questions elsewhere, and have one last question now, to be able to build my own scenario.. How do I add a lua file to my scenario to make markets work? I was told that, in order to use a market in game, I have to have placed the market already in map editor, and then after the layout is done, add a lua file to the scenario which would run the commands that add stuff to the market to sell/buy.
Thanks to anyone who can help me out with this.

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: How to make a working market?

Post by n9103 »

You're looking for "control.lua".
It's not a simple drag and drop deal, and usually needs to be hand programmed for each mod.
Being that there aren't any other mods that actually use the market, I don't know that you can even find relevant parts from other scripts.
But, relevant code or not, read through the control.lua that are in a lot of the mods, as well as the wiki.
I don't even know if you'll be able to use the market functions that are hard-coded into the game, and you may just end up having to make a custom entity that only looks like the market, and scripting it from there.

So, yea... lot more work than you probably thought, but I'm sure many people would enjoy a working market, particularly if it achieves multiplayer compatibility.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

Devcod
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Aug 08, 2014 8:14 pm
Contact:

Re: How to make a working market?

Post by Devcod »

https://forums.factorio.com/wiki/inde ... Lua/Market
https://forums.factorio.com/wiki/inde ... ntitybytag
How to use it: control.lua:

Code: Select all

require "defines"
game.oninit(function()
local market = game.getentitybytag("market")
market.addmarketitem{price={{"iron-ore", 10}}, offer={type="give-item", item="copper-ore"}}
end)
Read more about scripting/modding if you don't know how this works or what to do with it. As always - I am not at home so I can't test this. I think you need to do something in map editor before it works, at least according to "getentitybytag" description.

Post Reply

Return to “Maps and Scenarios”

Who is online

Users browsing this forum: No registered users