I'm new to Factorio modding and am looking for advice from people more experienced than I am.
I had an idea to implement a large assembly machine whose inputs and outputs are fed through underground belts that pass through to the other side of the assembly machine so that another one can be easily placed after it. I understand most people would consider this to be unfun and overpowered but personally I'm interested in the kind of late game designs this would enable.
Rather than implementing this as a special type of entity, I realized it would make a lot of sense to implement a special type of underground belt which could be attached to existing assemblers as well as smelters and other various entities. That way, the same pattern could be applied to other types of buildings without having to reimplement anything.
I'm thinking it may be possible to do this with 2 entities: when the belt is built it would create an inserter in the background connecting the underground belt to the assembly machine, which would be deconstructed along with the belt if destroyed
There would be two types of belts, one for an "input belt" which has the inserter going into the assembler and an "output belt" with the inserter going from the assembler to the belt. However, I don't know if this is possible as the inserter seems like it would need to be "underneath" the assembler/smelter/whatever container it's passing through.
Are entities allowed to overlap like that?
Another plausible way to do this would be to make a special underground belt that also acts as a loader attached to the assembly machine. From what I've read this doesn't seem possible because "hybrid entities" are not valid prototypes, and moreover it seems like there may have to be some kind of priority splitter behavior involved.
Is the approach with the automatically created inserter viable? If not, is there a different/better way to do what I'm thinking about?
Any help/thoughts are appreciated.
Underground Belt as Input/Output
-
- Burner Inserter
- Posts: 6
- Joined: Mon May 31, 2021 6:41 am
- Contact:
Underground Belt as Input/Output
Last edited by borthralla on Tue Jun 01, 2021 4:06 pm, edited 1 time in total.
Re: Underground Belt as Input/Output
Yes, a hidden inserter would work fine. Inserters can work with buildings even if their collision boxes overlap.
Your idea is basically the same as Miniloader, but with the direction of the underground belts reversed.
Your idea is basically the same as Miniloader, but with the direction of the underground belts reversed.
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Underground Belt as Input/Output
Belts render below buildings, so you might not even need special undergrounds (except for the visuals). You will need an invisible inserter with non-fixed drop vector though.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
-
- Burner Inserter
- Posts: 6
- Joined: Mon May 31, 2021 6:41 am
- Contact:
Re: Underground Belt as Input/Output
It's good to know that the inserter approach is viable. I've taken a look at what miniloader does and I think I might be able to do something along those same lines although maybe a little less complex.
I think I'll do this for blue belts only, which means I won't have to worry about variable belt speeds/inserter speed requirements.
One detail is I think it would make sense if the inserters were able to fully load/unload from the blue belt into/from the assembler. It seems like miniloader creates two different inserters in the same spot where the inserters use different pickup/drop positions to configure which goes to which lane. I think I should be able to go with that approach as well: I'll need to make a custom insterter that is able to saturate a full lane of a blue belt and whose pickup/drop positions are modifiable at runtime (there seems to be an option in the prototype for that). When the underground belt is placed, I would create two inserters picking up from/dropping off to different lanes. I'll need to modify the offset of the pickup/drop positions of each inserter respectively depending on the direction of the placed underground belt.
So the mod would look something like this:
Three new entities:
underground-loader, underground-unloader, underground-inserter
The underground loader and unloader would be the same as the express underground belt prototypes except for graphical changes and recipe.
Underground-inserter would be a custom inserter with rotation speed/extension speed enough to do a full lane from a blue belt or ~23 items/second. It would also have to allow_custom_vectors set to True so that the pickup and drop positions can be configured when they're placed at runtime.
The prototypes need to be created for all the entities as well as tech/items/recipes for the underground-loader and underground-unloader.
That will be done in data.lua.
In control.lua, I'll need to hook into the event api for when the underground loaders or unloaders are built or destroyed.
When a underground-loader is placed, I need to check the belt's belt_to_ground_type. If the belt is going up, then no need to do anything. If it's going downward, then I need to create both of the inserters pointing from the belt to the assembler with pickup_positions set to opposing lanes based off the direction of the belt.
When an underground-unloader is placed, I'll need to check if the belt_to_ground_type is up, in which case I'll need to create two inserters with drop_positions set to different lanes based off the direction of the outgoing belt.
If the corresponding belt gets destroyed, the inserters will need to be destroyed along with it.
One thing I've yet to consider is what happens if the building/container is not present when the belt is built. I'm not sure if the invisible inserter would prevent normal buildings from being built over it even if they're invisible, it seems like that might be the case. I could prevent the construction of the loader if there are no container-like entities in the area, and I could also check whenever something is destroyed that their aren't any underground inserters within the bounding box of the destroyed entity.
Another potential approach is to place the inserters on top of the underground belt itself. This is probably a better approach as long as I can configure pickup/drop positions to be the tile the inserter is sitting on. That way I don't have to worry about overlapping with other entities and causing problems.
Seems like this should be doable, except I'm essentially reimplementing miniloader but instead of a 1x1-loader entity its on top of an underground belt. Maybe I should talk with Therax to see if he would be open to incorporating this kind of design into his mod.
I think I'll do this for blue belts only, which means I won't have to worry about variable belt speeds/inserter speed requirements.
One detail is I think it would make sense if the inserters were able to fully load/unload from the blue belt into/from the assembler. It seems like miniloader creates two different inserters in the same spot where the inserters use different pickup/drop positions to configure which goes to which lane. I think I should be able to go with that approach as well: I'll need to make a custom insterter that is able to saturate a full lane of a blue belt and whose pickup/drop positions are modifiable at runtime (there seems to be an option in the prototype for that). When the underground belt is placed, I would create two inserters picking up from/dropping off to different lanes. I'll need to modify the offset of the pickup/drop positions of each inserter respectively depending on the direction of the placed underground belt.
So the mod would look something like this:
Three new entities:
underground-loader, underground-unloader, underground-inserter
The underground loader and unloader would be the same as the express underground belt prototypes except for graphical changes and recipe.
Underground-inserter would be a custom inserter with rotation speed/extension speed enough to do a full lane from a blue belt or ~23 items/second. It would also have to allow_custom_vectors set to True so that the pickup and drop positions can be configured when they're placed at runtime.
The prototypes need to be created for all the entities as well as tech/items/recipes for the underground-loader and underground-unloader.
That will be done in data.lua.
In control.lua, I'll need to hook into the event api for when the underground loaders or unloaders are built or destroyed.
When a underground-loader is placed, I need to check the belt's belt_to_ground_type. If the belt is going up, then no need to do anything. If it's going downward, then I need to create both of the inserters pointing from the belt to the assembler with pickup_positions set to opposing lanes based off the direction of the belt.
When an underground-unloader is placed, I'll need to check if the belt_to_ground_type is up, in which case I'll need to create two inserters with drop_positions set to different lanes based off the direction of the outgoing belt.
If the corresponding belt gets destroyed, the inserters will need to be destroyed along with it.
One thing I've yet to consider is what happens if the building/container is not present when the belt is built. I'm not sure if the invisible inserter would prevent normal buildings from being built over it even if they're invisible, it seems like that might be the case. I could prevent the construction of the loader if there are no container-like entities in the area, and I could also check whenever something is destroyed that their aren't any underground inserters within the bounding box of the destroyed entity.
Another potential approach is to place the inserters on top of the underground belt itself. This is probably a better approach as long as I can configure pickup/drop positions to be the tile the inserter is sitting on. That way I don't have to worry about overlapping with other entities and causing problems.
Seems like this should be doable, except I'm essentially reimplementing miniloader but instead of a 1x1-loader entity its on top of an underground belt. Maybe I should talk with Therax to see if he would be open to incorporating this kind of design into his mod.
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Underground Belt as Input/Output
Keep in mind that inserters always pick up from both lanes. The pickup position only selects the preferred lane. Contrary to dropoff which only happens to a single lane.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.