Page 1 of 1

Belt neighbours

Posted: Sun Jun 16, 2019 7:27 pm
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.

Re: Belt neighbours

Posted: Sun Jun 16, 2019 7:34 pm
by Nexela
Seconded

Re: Belt neighbours

Posted: Sun Jun 16, 2019 9:13 pm
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.

Re: Belt neighbours

Posted: Mon Jun 17, 2019 9:09 pm
by Staplergun
Darkfrei I placed your additional piece about loaders into the main request.

Re: Belt neighbours

Posted: Tue Jul 23, 2019 10:37 pm
by Bilka
Okay, added for the next version.