Page 1 of 1

questions about writing a mod

Posted: Mon Aug 11, 2014 10:48 pm
by rbabiak
Hi all.

I have two ideas for mods that I would like to build. Having trouble finding the info on how to do what I want. I have found the tutorial on how to write a mod but was looking around for the control.lua for the splitters and tracks.

What I want to make is two new track items, the first is a splitter that has a pass through, and three output channels. A filter on the splitter lets you chose the type of item that is split out onto that output. I figured it would be easy to combine the code for a filter inserter and a splitter to atleast get a one channel splitter working. But I can't find and LUA code for either the inserter or the splitter.

The second is a buffer track, basically a track with a steel chest attached. If the output side is full (no more can go out) then the input builds up in the chest until it is full. And as such create a buffer of the goods going on. this would be useful for while one is rearranging part of the base. part of the balancing would that it takes power equal to a inserter to run that track segment, no power and it works like a normal track segment. Again cant find any code for the track to allow for it to build up a surplus in hand, was thinking a combination of the chest and track code.

One other question, is the size of a steel chest the maximum storage slots for a item. I was thinking of a warehouse building that is like a chest, but much larger.

Since I am two for two striking out, am i missing something basic here?

Re: questions about writing a mod

Posted: Mon Aug 11, 2014 11:17 pm
by FreeER
rbabiak wrote:Since I am two for two striking out, am i missing something basic here?
Simply that these are not easily possible. Most of how things work in Factorio is written in C++, which means that it is 'invisible and unchangeable' aka hardcoded. Obviously, at least when looking at Belt Lane Splitters and Terminal Chests and Belt Switchers, this is possible, it's just that to do it the modders have to do practically all of the work (seeing if there are items to move, seeing if there is anywhere to place those items, moving those items, etc.) theirselves in Lua and/or take advantage of understanding how the default types truly work.

My suggestion, honestly, would be to look at the code of those three mods (and their threads) and see how they're implemented...And ask questions when you see something you don't understand (I'm assuming that you have some basic understanding already of modding Factorio). 'Obviously' it'd be polite to ask the authors first if they mind you looking.

This will probably change eventually, at least we all hope it will :), but the devs aren't truly focused on making modding easier right now (which is fairly understandable in my opinion).