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.
How to make a working market?
-
- Burner Inserter
- Posts: 7
- Joined: Wed Nov 19, 2014 7:34 pm
- Contact:
Re: How to make a working market?
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.
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.
Re: How to make a working market?
https://forums.factorio.com/wiki/inde ... Lua/Market
https://forums.factorio.com/wiki/inde ... ntitybytag
How to use it: control.lua:
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.
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)