Feasibility Question - Mod to control assembler output?

Place to get help with not working mods / modding interface.
Post Reply
Crogdor
Manual Inserter
Manual Inserter
Posts: 1
Joined: Tue May 17, 2016 9:38 pm
Contact:

Feasibility Question - Mod to control assembler output?

Post by Crogdor »

Hello,

I'd like to make a mod that creates dynamically controlled factory output by using the circuit network. A description of several phases of development is below. Is something like this feasible, or has it already been done? I couldn't find anything in my search through existing mods.

Here is my vision:

Phase 1:

Extend/create an assembly machine entity that can be connected to the circuit network, such that the machine's output is the same as the first signal received on the wire.

Phase 2:

Create a new circuit network machine called a recipe splitter (or something like that), that has one input wire and one output wire. This takes as input a craftable item, and outputs the constituent ingredients on the output wire. For example, if the input is an electronic circuit, then the output wire has one iron plate and 3 copper wire. Another option here is to have multiple output wires, one with each constituent ingredient, but I wanted to start simple.

Phase 3:

Create a new type of requester chest that attaches to the circuit network, but instead of signalling its content on the wire, it requests what is being signaled on the wire. So if the input signal is one iron plate and 3 copper wire, then that is what the chest requests. This chest or the recipe splitter above could also be connected to a multiplier to help scale the number of requested items to reduce bottlenecking the logistic drones.

Conclusion:

Once all phases are complete, one should have the ability to blueprint these new structures/entities together, along with inserter arms and wiring. Then, the requested item is produced so long as the input items are on the logistics network. And even if the input items are not on the logistics network, one could simply chain more of these modular sections together to create those input items. The final result would be the possibility of creating reusable assembly plants that can be repurposed to meet factory demands.

But is this possible? Thoughts?

bluMyst
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sun May 15, 2016 3:53 am
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by bluMyst »

From what I've read so far, Factorio modding is extremely basic and crude right now. It's really just a bare-bones framework to be (hopefully?) extended later. Either that or the documentation is just missing a huge chunk of information. At the moment, it's not possible to read anything from a circuit network, and it's also not possible to write anything to a circuit network. You can extend entities that already interact with a circuit network (e.g. combinators) but you can't change how they behave. You can just change superficial stuff like how they look and how much power they use. This is handy if you have a paint-by-numbers idea like "a turret that runs on water", but if you want to do anything that's a little more outside the box, it's not possible.

In the next update, it'll be possible to read from circuit networks, but still no writing to them.

I have some theories on how to do some very hackish stuff to get around these limitations, but the end user would have to manually run Lua code in the console to get them to work, so they're not exactly good solutions.

Edit: In spite of all this, it is possible to change the recipe on an assembly machine. You can also view what's in its current inventory. I have no idea if it's possible to read recipe information from the game, but I think the 'data' variable might have something like that.
In my infinite ambivalence.

Sean Mirrsen
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Wed Apr 27, 2016 6:30 pm
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by Sean Mirrsen »

It's probably doable, but not in the way you propose.

You can read recipe information from in-game. You can read an assembly machine's recipe information. You can set a requester chest's request slot contents.

Through some Lua sorcery, you can create a setup wherein placing down your "special" assembly machine automagically places down some invisible components, such as a requester chest and a constant combinator. They're not actually going to connect via the signal network, because that's not going to be very useful. Instead, the Lua script would read the output inventory of the constant combinator (you wouldn't be able to manually select the factory or the requester chest), check for a recipe that can be created by the factory it is attached to (by number of ingredients, crafting type), then set the requester chest's request slots to match the types and numbers of items that are required for crafting everything you have put into the constant combinator. The script will then set the factory's crafting order to the first item on its list, and will continue iterating through the items in the list as the factory makes the items, in the amounts you put them in. So that if you put in five transport belts and five inserters, the factory will keep producing batches of five of each as long as robots will keep supplying the requester chest with materials. Either the script itself or a cleverly hidden invisible inserter arm can move items from the requester chest to the factory.

So it's kind of doable. It's probably kind of doable in sort of the way you want, too, but it's going to be much, much more difficult to script. I wouldn't take on scripting even just the compact solution I described. ._.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by Rseding91 »

bluMyst wrote:From what I've read so far, Factorio modding is extremely basic and crude right now. It's really just a bare-bones framework to be (hopefully?) extended later.
Hardly http://lua-api.factorio.com/0.12.33/
bluMyst wrote:Either that or the documentation is just missing a huge chunk of information. At the moment, it's not possible to read anything from a circuit network, and it's also not possible to write anything to a circuit network. You can extend entities that already interact with a circuit network (e.g. combinators) but you can't change how they behave. You can just change superficial stuff like how they look and how much power they use. This is handy if you have a paint-by-numbers idea like "a turret that runs on water", but if you want to do anything that's a little more outside the box, it's not possible.
That's how modding works. You can't make Factorio in Fallout 4 and you can't make Fallout 4 in Factorio - "modding" does not imply you can change how the game works from the ground up.
bluMyst wrote:In the next update, it'll be possible to read from circuit networks, but still no writing to them.
Constant combinators have always been able to write to the circuit network. The entire circuit network system is built around entities - entities store the signals that the network uses and as such you can't just "write" to the circuit network through the Lua API or any other part of code.
bluMyst wrote:I have some theories on how to do some very hackish stuff to get around these limitations, but the end user would have to manually run Lua code in the console to get them to work, so they're not exactly good solutions.

Edit: In spite of all this, it is possible to change the recipe on an assembly machine. You can also view what's in its current inventory. I have no idea if it's possible to read recipe information from the game, but I think the 'data' variable might have something like that.
You refer to the "data" variable for reading runtime data which shows you don't even know how basic modding works in Factorio which just further discredits anything you're saying...
If you want to get ahold of me I'm almost always on Discord.

bluMyst
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sun May 15, 2016 3:53 am
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by bluMyst »

Wow, sorry. I didn't expect to run into an actual developer. You guys are really active on the forums. :( I was mostly trying to answer the question based on what I knew from reading the official API docs, but I was also venting a lot of frustration at how limited it all feels. For example, I was hoping to be able to create a PID controller block, but I don't think the current API would allow something like that. There's nothing in the documentation that could be used to interact with, for example, a constant combinator, in order to change its circuit network values. At least nothing that I've found. But then again, I haven't looked at the wiki much yet. I've read through the official docs several times, though. But that's why I didn't know about how 'data' worked - because things like that are mentioned on the wiki instead of the docs.

Anyway, sorry. I should've toned it down, but I just didn't think someone from the actual development team would be here. You guys really have made an awesome game, and it's a testament to how much I like it that I can get so frustrated when something isn't quite right.
In my infinite ambivalence.

User avatar
ArderBlackard
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Thu May 05, 2016 12:41 pm
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by ArderBlackard »

bluMyst wrote:There's nothing in the documentation that could be used to interact with, for example, a constant combinator, in order to change its circuit network values. At least nothing that I've found.
It seems that this function does exactly the thing you are looking for: LuaEntity.set_circuit_condition
Gib dich hin bis du Glück bist

bluMyst
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sun May 15, 2016 3:53 am
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by bluMyst »

ArderBlackard wrote:It seems that this function does exactly the thing you are looking for: LuaEntity.set_circuit_condition
You know, I'd completely dismissed that little function because it looked like you could only use it to set the conditions on things like decider combinators and arithmetic combinators. I completely missed that little 'ConstantCombinatorParameters' part. Well that's more than a little embarrassing.
In my infinite ambivalence.

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 950
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by ratchetfreak »

Rseding91 wrote: That's how modding works. You can't make Factorio in Fallout 4 and you can't make Fallout 4 in Factorio - "modding" does not imply you can change how the game works from the ground up.
But some features that could be seen as fundamental are sill missing from the mod API. And it feels like a uphill battle trying to get them.
Rseding91 wrote:
bluMyst wrote:In the next update, it'll be possible to read from circuit networks, but still no writing to them.
Constant combinators have always been able to write to the circuit network. The entire circuit network system is built around entities - entities store the signals that the network uses and as such you can't just "write" to the circuit network through the Lua API or any other part of code.
but constant combinators are limited in how many signals you can let it send to the network.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by Rseding91 »

ratchetfreak wrote:But some features that could be seen as fundamental are sill missing from the mod API. And it feels like a uphill battle trying to get them.
The mod interface requests sub forum is always open for ideas. Ones that are actually feasible and have value I add. Just look at the additions for 0.13: viewtopic.php?f=34&t=25270
bluMyst wrote:but constant combinators are limited in how many signals you can let it send to the network.
That's just how the circuit network works. Everything that the backing entities have access to is exposed through the Lua API. A "Circuit Network" is a collection of entities of which each has some specific number of signals it sends into the network. When an entity is added it sends the signals it has and when it's removed it stops sending them.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5148
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by Klonan »

Crogdor wrote:Hello,

I'd like to make a mod that creates dynamically controlled factory output by using the circuit network. A description of several phases of development is below. Is something like this feasible, or has it already been done? I couldn't find anything in my search through existing mods.

Here is my vision:

Phase 1:

Extend/create an assembly machine entity that can be connected to the circuit network, such that the machine's output is the same as the first signal received on the wire.

Phase 2:

Create a new circuit network machine called a recipe splitter (or something like that), that has one input wire and one output wire. This takes as input a craftable item, and outputs the constituent ingredients on the output wire. For example, if the input is an electronic circuit, then the output wire has one iron plate and 3 copper wire. Another option here is to have multiple output wires, one with each constituent ingredient, but I wanted to start simple.

Phase 3:

Create a new type of requester chest that attaches to the circuit network, but instead of signalling its content on the wire, it requests what is being signaled on the wire. So if the input signal is one iron plate and 3 copper wire, then that is what the chest requests. This chest or the recipe splitter above could also be connected to a multiplier to help scale the number of requested items to reduce bottlenecking the logistic drones.

Conclusion:

Once all phases are complete, one should have the ability to blueprint these new structures/entities together, along with inserter arms and wiring. Then, the requested item is produced so long as the input items are on the logistics network. And even if the input items are not on the logistics network, one could simply chain more of these modular sections together to create those input items. The final result would be the possibility of creating reusable assembly plants that can be repurposed to meet factory demands.

But is this possible? Thoughts?

This mod did something similar:

viewtopic.php?f=14&t=12471

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 950
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by ratchetfreak »

Rseding91 wrote:
ratchetfreak wrote:But some features that could be seen as fundamental are sill missing from the mod API. And it feels like a uphill battle trying to get them.
The mod interface requests sub forum is always open for ideas. Ones that are actually feasible and have value I add. Just look at the additions for 0.13: viewtopic.php?f=34&t=25270
bluMyst wrote:but constant combinators are limited in how many signals you can let it send to the network.
That's just how the circuit network works. Everything that the backing entities have access to is exposed through the Lua API. A "Circuit Network" is a collection of entities of which each has some specific number of signals it sends into the network. When an entity is added it sends the signals it has and when it's removed it stops sending them.
First rule of a moddable game, anything you add people are going to want to mod.

For example the circuit network, to mod that you need to be able to read from the circuit network easily (not the current binary search hack) and adding your own signal outputs to the network. It took a new release to add functionality that should have been there before the combinators were added. It wouldn't have been that hard to say LuaEntity::get_circuit_input(connectorIndex)

Sean Mirrsen
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Wed Apr 27, 2016 6:30 pm
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by Sean Mirrsen »

ratchetfreak wrote:First rule of a moddable game, anything you add people are going to want to mod.

For example the circuit network, to mod that you need to be able to read from the circuit network easily (not the current binary search hack) and adding your own signal outputs to the network. It took a new release to add functionality that should have been there before the combinators were added. It wouldn't have been that hard to say LuaEntity::get_circuit_input(connectorIndex)
First rule of a complex game, don't add modding support for a feature before you're sure it works smoothly when hard-coded.

And as the game is not written in Lua, every access point into the code needs to be explicitly defined. I can't say how easy it is to add the Lua hooks in this game's code, but I can't imagine it doing the code's stability any wonders. So releasing a hardcoded feature, giving it to the players to stress-test, fixing any bugs, and then opening it to modding (and then fixing the bugs that cope up then), is the smart thing to do in my opinion.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by Rseding91 »

ratchetfreak wrote:... It wouldn't have been that hard to say LuaEntity::get_circuit_input(connectorIndex)
You know absolutely nothing about how much work is involved in adding anything in.
If you want to get ahold of me I'm almost always on Discord.

AenAllAin
Long Handed Inserter
Long Handed Inserter
Posts: 61
Joined: Sat Apr 02, 2016 3:10 am
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by AenAllAin »

Rseding91 wrote:
ratchetfreak wrote:... It wouldn't have been that hard to say LuaEntity::get_circuit_input(connectorIndex)
You know absolutely nothing about how much work is involved in adding anything in.
@ratchetfreak: Aww! Come on dude; that is harsh. Just relax a little bit. They made some software and decided to do early access sharing (I assume to promote feedback and guided development) ...it's easy to poke around at the things that may have been missed or mistakes that were made, but shit happens; it's better to have done than to don't. Look at it from a holistic perspective; the parts of this game that have been implemented, have been implemented well. The game stands out not just for its concept, but just as much for its refined aspects and nuances. The initial play-ability is striking in its attention to detail. So you've gotta take that into account, and just respect the pacing and priorities the Devs have set. They do have an open forum for voicing complaints and putting forth your issues to at least be considered ...look at me, they haven't kicked me out yet (...they just ignore me mostly ...probably because I pissed-off Klonan by pooping on his baby/Laser Beam Turret mod for having less damage throughput than the default turrets ...probably because the graphical rendering process is a blocking process or something and seems to prevent or slow-down the fire rate ..but anyway, I digress). Also, consider the size of their operation; they are just starting out. They need time to grow into their success and expand to meet the community demand. All things considered they are doing really well. You can't compare them to Microsoft that monolithic turd of a company soaking up industry resources and market share to produce the shoddiest, most half-assed, re-packaging of stolen ideas and intellectual property to have ever been seen in human history to date. I could go on and on about the incalculable damage Microsoft has wrought on the software community, but that is beside the point. You cannot compare Factorio or it's Devs to the bastardization of software that is Windows and all things Microsoft.

But getting back to the point, @op: I'm not saying it is a bad idea, but why is it you are trying to throttle production at the manufacturing device level? Isn't that a logistics issue? If you don't put anything in; you don't have to worry about getting anything out, and vice versa ideally. You want as much as possible for your factory output to keep pace with however much you are trying to throw at it. So why isn't the focus on logistic elements?

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 950
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Feasibility Question - Mod to control assembler output?

Post by ratchetfreak »

I'm sorry I just get annoyed when I see 90% of the logic required already in the codebase (and there are clear uses of it already) but proposals to use that logic elsewhere are shut down because "too hard".

Same with filterable chests, you already have a arbitrarily-filterable inventory in the cargo wagon. The only thing that still needs adding there is logibot logic but they already have logic to prefer chests which already have some of the item needing to be stored. Then you only need to decide whether filtered slots get priority over a half-filled slot without filter.

Post Reply

Return to “Modding help”