Belt neighbours

Post Reply
Staplergun
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Sun Mar 25, 2018 5:34 am
Contact:

Belt neighbours

Post by Staplergun »

Neighbours method for all four types of transport belts
  • splitters
  • transport-belt
  • belt-to-ground
  • loaders
It needs to perform input/output validation, and for splitters self check validation (so it doesn't return itself as a neighbour).

What I mean by this:
Check if the current entity can actually output into the forward entity
Check if the neighbour entity can properly input into this (ie: no pushing into the hood of a belt-to-ground or side of a splitter)
It doesn't have to be whether both input lines can reach, just if at least one can input/output.

It should return a table of either inputs and outputs, or all entities with some sort of indicator of whether each entity is an input or output to the current entity.

If possible, the ability to call neighbours.input or neighbours.output individually to only receive those specific tables without running the entire neighbours method and getting both tables.

A use example would be

Code: Select all

entity.neighbours ->
{
	input = {}
	output = {}
}
For entity type transport-belt or belt-to-ground
The table property input gives an array of up to three entity references, or an empty table

Code: Select all

neighbours.input ->
{
	LuaEntity,
	LuaEntity,
	LuaEntity
}
For these two types, it's only possible to output to a single entity, so either an array with a single entry (for similar functionality as the splitter), or a singular entity reference, much like the current neighbours method behaves on a belt to ground.

Code: Select all

neighbours.output ->
LuaEntity
or
{
	LuaEntity
} 
With splitters, there's only two outputs and/or two inputs.

The table property input gives an array of up to two entity references, or an empty table

Code: Select all

neighbours.input ->
{
	LuaEntity,
	LuaEntity
}
The table property output gives an array of up to two entity references, or an empty table

Code: Select all

neighbours.output ->
{
	LuaEntity,
	LuaEntity
}
The loader type would return the input and output like any of the above, with one being the entity its dropping items into or extracting items from, and the belt it's pushing to/from.


The biggest thing here is that these types of entities are very different from pipes and anything with fluidboxes. It simply cannot act the same.
Last edited by Staplergun on Thu Jun 20, 2019 4:22 am, edited 7 times in total.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Belt neighbours

Post by Nexela »

Seconded

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Belt neighbours

Post by darkfrei »

+1
https://lua-api.factorio.com/latest/Lua ... neighbours

Now it's done for underground belts, nor the normal ones. By loaders it can be belt + target entity or source entity + belt.

Staplergun
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Sun Mar 25, 2018 5:34 am
Contact:

Re: Belt neighbours

Post by Staplergun »

Darkfrei I placed your additional piece about loaders into the main request.

Bilka
Factorio Staff
Factorio Staff
Posts: 3133
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Belt neighbours

Post by Bilka »

Okay, added for the next version.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Implemented mod requests”