Skip to content

Instantly share code, notes, and snippets.

Created July 18, 2016 03:25
Show Gist options
  • Save anonymous/86d51ab71db6fde29eaf5b6af82635a1 to your computer and use it in GitHub Desktop.
Save anonymous/86d51ab71db6fde29eaf5b6af82635a1 to your computer and use it in GitHub Desktop.
factorissimo control.lua line 444–>
else
-- CREATE CONNECTION
-- TODO nerf connection check rate
local px = pconn.outside_x + structure.parent.position.x+0.5
local py = pconn.outside_y + structure.parent.position.y+0.5
local e3 = parent_surface.find_entity("transport-belt", {x = px, y = py})
or parent_surface.find_entity("fast-transport-belt", {x = px, y = py})
or parent_surface.find_entity("express-transport-belt", {x = px, y = py})
or parent_surface.find_entity("purple-transport-belt", {x = px, y = py})
or parent_surface.find_entity("green-transport-belt", {x = px, y = py})
local e4 = parent_surface.find_entity("pipe", {x = px, y = py})
or parent_surface.find_entity("stone-pipe", {x = px, y = py})
or parent_surface.find_entity("copper-pipe", {x = px, y = py})
or parent_surface.find_entity("steel-pipe", {x = px, y = py})
or parent_surface.find_entity("plastic-pipe", {x = px, y = py})
or parent_surface.find_entity("bronze-pipe", {x = px, y = py})
or parent_surface.find_entity("brass-pipe", {x = px, y = py})
or parent_surface.find_entity("ceramic-pipe", {x = px, y = py})
or parent_surface.find_entity("titanium-pipe", {x = px, y = py})
or parent_surface.find_entity("tungsten-pipe", {x = px, y = py})
local e5 = parent_surface.find_entity("pipe-to-ground", {x = px, y = py})
or parent_surface.find_entity("copper-pipe-to-ground", {x = px, y = py})
or parent_surface.find_entity("steel-pipe-to-ground", {x = px, y = py})
or parent_surface.find_entity("plastic-pipe-to-ground", {x = px, y = py})
or parent_surface.find_entity("bronze-pipe-to-ground", {x = px, y = py})
or parent_surface.find_entity("brass-pipe-to-ground", {x = px, y = py})
or parent_surface.find_entity("ceramic-pipe-to-ground", {x = px, y = py})
or parent_surface.find_entity("titanium-pipe-to-ground", {x = px, y = py})
or parent_surface.find_entity("tungsten-pipe-to-ground", {x = px, y = py})
if e3 then
if e3.direction == pconn.direction_in then
dbg("Connecting inwards belt")
local e = place_entity(surface, e3.name, pconn.inside_x, pconn.inside_y, structure.parent.force)
if e then
e.direction = e3.direction
e3.rotatable = false
structure.connections[id] = {from = e3, to = e, inside = e, outside = e3, conn_type = "belt"}
end
elseif e3.direction == pconn.direction_out then
dbg("Connecting outwards belt")
local e = place_entity(surface, e3.name, pconn.inside_x, pconn.inside_y, structure.parent.force)
if e then
e.direction = e3.direction
e3.rotatable = false
structure.connections[id] = {from = e, to = e3, inside = e, outside = e3, conn_type = "belt"}
end
end
elseif e4 then
dbg("Connecting pipe")
local e = place_entity(surface, e4.name, pconn.inside_x, pconn.inside_y, structure.parent.force, pconn.direction_in)
if e then
structure.connections[id] = {from = e, to = e4, inside = e, outside = e4, conn_type = "pipe"}
end
elseif e5 then
if e5.direction == pconn.direction_in then
dbg("Connecting pipe to ground")
local e = place_entity(surface, e5.name, pconn.inside_x, pconn.inside_y, structure.parent.force, pconn.direction_in)
if e then
e5.rotatable = false
structure.connections[id] = {from = e, to = e5, inside = e, outside = e5, conn_type = "pipe"}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment