Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions connections/belt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ Belt = {}
Belt.color = {r = 0, g = 183/255, b = 0}
Belt.entity_types = {"transport-belt", "underground-belt"}
Belt.unlocked = function(force) return true end

Belt.indicator_settings = {"d0"}

local INSERT_POS = {
["transport-belt"] = 0.75, -- 1 - 8/32
["underground-belt"] = 0.25 -- 0.5 - 8/32
}

if (mods or script.active_mods)["deadlock-beltboxes-loaders"] then
table.insert(Belt.entity_types, "loader-1x1")
table.insert(INSERT_POS, {["loader-1x1"] = 0.75}) -- 1 - 8/32
end

local function calc_delays(speed1, speed2)
-- Belt connections will transfer a maximum of 1 item per tick per lane
local speed = math.min(8, math.min(speed1, speed2))
Expand All @@ -17,19 +26,14 @@ local function calc_delays(speed1, speed2)
return delays
end

local INSERT_POS = {
["transport-belt"] = 0.75, -- 1 - 8/32
["underground-belt"] = 0.25, -- 0.5 - 8/32
}


local opposite = {
[defines.direction.north] = defines.direction.south, [defines.direction.south] = defines.direction.north,
[defines.direction.east] = defines.direction.west, [defines.direction.west] = defines.direction.east,
}

local function get_conn_facing(outside_entity, inside_entity, direction_out, direction_in)
local outside_dir, inside_dir, ot, it = 0, 0, outside_entity.type, inside_entity.type

if ot == "transport-belt" then
outside_dir = outside_entity.direction
elseif ot == "underground-belt" then
Expand All @@ -40,6 +44,7 @@ local function get_conn_facing(outside_entity, inside_entity, direction_out, dir
if direction_in ~= outside_dir then return nil end
end
end

if it == "transport-belt" then
inside_dir = inside_entity.direction
elseif it == "underground-belt" then
Expand All @@ -50,6 +55,17 @@ local function get_conn_facing(outside_entity, inside_entity, direction_out, dir
if direction_out ~= inside_dir then return nil end
end
end

if (mods or script.active_mods)["deadlock-beltboxes-loaders"] then
if ot == "loader-1x1" then
outside_dir = outside_entity.direction
end

if it == "loader-1x1" then
inside_dir = inside_entity.direction
end
end

if outside_dir ~= inside_dir then return nil end
--game.print("Direction: " .. outside_dir)
return outside_dir
Expand Down Expand Up @@ -135,4 +151,4 @@ Belt.tick = function (conn)
end

Belt.destroy = function (conn)
end
end
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"author": "MagmaMcFry",
"description": "Factorissimo 2 adds factory buildings to Factorio. Place them down, walk in, build your factories inside!",
"factorio_version": "1.1",
"dependencies": ["base >= 1.1.0"]
"dependencies": ["base >= 1.1.0", "?deadlock-beltboxes-loaders"]
}