From 2cf29d10faebd2bec646d3344404dc08380c0915 Mon Sep 17 00:00:00 2001 From: Marcel Petzold Date: Fri, 21 May 2021 01:04:06 +0200 Subject: [PATCH 1/3] Add Loaders Support (Deadlock's Mod) Adding support for all Loaders which where available if you play with Deadloack's Loader's mod (incl. check against the mod). --- connections/belt.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/connections/belt.lua b/connections/belt.lua index cedf622..c815bab 100644 --- a/connections/belt.lua +++ b/connections/belt.lua @@ -1,7 +1,13 @@ Belt = {} Belt.color = {r = 0, g = 183/255, b = 0} -Belt.entity_types = {"transport-belt", "underground-belt"} + +if (mods or script.active_mods)["deadlock-beltboxes-loaders"] then + Belt.entity_types = {"transport-belt", "underground-belt", "loader-1x1"} +else + Belt.entity_types = {"transport-belt", "underground-belt"} +end + Belt.unlocked = function(force) return true end Belt.indicator_settings = {"d0"} @@ -22,6 +28,12 @@ local INSERT_POS = { ["underground-belt"] = 0.25, -- 0.5 - 8/32 } +if (mods or script.active_mods)["deadlock-beltboxes-loaders"] then + table.insert(INSERT_POS, {["loader-1x1"] = 0.75,}) -- 1 - 8/32 +else + +end + local opposite = { [defines.direction.north] = defines.direction.south, [defines.direction.south] = defines.direction.north, @@ -39,6 +51,10 @@ local function get_conn_facing(outside_entity, inside_entity, direction_out, dir else if direction_in ~= outside_dir then return nil end end + elseif (mods or script.active_mods)["deadlock-beltboxes-loaders"] then + if ot == "loader-1x1" then + outside_dir = outside_entity.direction + end end if it == "transport-belt" then inside_dir = inside_entity.direction @@ -49,6 +65,10 @@ local function get_conn_facing(outside_entity, inside_entity, direction_out, dir else if direction_out ~= inside_dir then return nil end end + elseif (mods or script.active_mods)["deadlock-beltboxes-loaders"] then + 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) @@ -135,4 +155,4 @@ Belt.tick = function (conn) end Belt.destroy = function (conn) -end \ No newline at end of file +end From 5cc4fdd8237dc7612bb8362781aa5c0b432d8d12 Mon Sep 17 00:00:00 2001 From: Marcel Petzold Date: Fri, 21 May 2021 01:05:14 +0200 Subject: [PATCH 2/3] Added optional dependency for Deadlock's Loaders Added optional dependency for Deadlock's Loaders --- info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.json b/info.json index 9c14032..e7ff2d7 100644 --- a/info.json +++ b/info.json @@ -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"] } From f130965db3660c2901a65b2a5f2d7ca6f7504766 Mon Sep 17 00:00:00 2001 From: Marcel Petzold Date: Fri, 21 May 2021 01:46:19 +0200 Subject: [PATCH 3/3] Update belt.lua Code rewrite to simply extend the tables as needed and less use of unnecessery if-statements. --- connections/belt.lua | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/connections/belt.lua b/connections/belt.lua index c815bab..6e68143 100644 --- a/connections/belt.lua +++ b/connections/belt.lua @@ -1,17 +1,20 @@ 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 - Belt.entity_types = {"transport-belt", "underground-belt", "loader-1x1"} -else - Belt.entity_types = {"transport-belt", "underground-belt"} + table.insert(Belt.entity_types, "loader-1x1") + table.insert(INSERT_POS, {["loader-1x1"] = 0.75}) -- 1 - 8/32 end -Belt.unlocked = function(force) return true end - -Belt.indicator_settings = {"d0"} - 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)) @@ -23,18 +26,6 @@ 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 -} - -if (mods or script.active_mods)["deadlock-beltboxes-loaders"] then - table.insert(INSERT_POS, {["loader-1x1"] = 0.75,}) -- 1 - 8/32 -else - -end - - 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, @@ -42,6 +33,7 @@ local opposite = { 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 @@ -51,11 +43,8 @@ local function get_conn_facing(outside_entity, inside_entity, direction_out, dir else if direction_in ~= outside_dir then return nil end end - elseif (mods or script.active_mods)["deadlock-beltboxes-loaders"] then - if ot == "loader-1x1" then - outside_dir = outside_entity.direction - end end + if it == "transport-belt" then inside_dir = inside_entity.direction elseif it == "underground-belt" then @@ -65,11 +54,18 @@ local function get_conn_facing(outside_entity, inside_entity, direction_out, dir else if direction_out ~= inside_dir then return nil end end - elseif (mods or script.active_mods)["deadlock-beltboxes-loaders"] then + 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