Skip to content

Commit

Permalink
Fixed inserter placement with configuration mode enabled #201
Browse files Browse the repository at this point in the history
  • Loading branch information
KiwiHawk committed Oct 28, 2024
1 parent e1c4fd1 commit b94ae93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions bobinserters/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Version: 1.3.1
Date: ???
Bugfixes:
- Fixed inserter placement with configuration mode enabled #201
- Fixed crash when opening inserter preview #204
---------------------------------------------------------------------------------------------------
Version: 1.3.0
Expand Down
12 changes: 5 additions & 7 deletions bobinserters/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,6 @@ end
function bobmods.logistics.set_positions(entity, player_index)
if storage.bobmods.logistics[player_index].enabled then
local force = game.players[player_index].force
local direction = (entity.direction / 2) + 1

local long_unlocked = tech_unlocked(force, bobmods.inserters.long_technology)
local more_unlocked = tech_unlocked(force, bobmods.inserters.more_technology)
Expand Down Expand Up @@ -968,28 +967,27 @@ function bobmods.logistics.set_positions(entity, player_index)
set_both_positions(entity, pickup_position, full_drop_position)
end

if storage.bobmods.logistics[player_index].enabled2 and remote.interfaces.bobinserters then
if entity.type ~= "entity-ghost" and storage.bobmods.logistics[player_index].enabled2 and remote.interfaces.bobinserters then
local pickup_position =
remote.call("bobinserters", "get_position", { position = storage.bobmods.logistics[player_index].pickup })
local drop_position =
remote.call("bobinserters", "get_position", { position = storage.bobmods.logistics[player_index].drop })
local drop_offset =
remote.call("bobinserters", "get_offset", { position = storage.bobmods.logistics[player_index].offset })

local direction = (entity.direction / 2)
if direction == 2 then -- 2 is up, because inserters are backwards.
if entity.direction == defines.direction.north then
pickup_position = pickup_position
drop_position = drop_position
drop_offset = drop_offset
elseif direction == 3 then -- right
elseif entity.direction == defines.direction.east then
pickup_position = { x = -pickup_position.y, y = pickup_position.x }
drop_position = { x = -drop_position.y, y = drop_position.x }
drop_offset = { x = -drop_offset.y, y = drop_offset.x }
elseif direction == 0 then -- down
elseif entity.direction == defines.direction.south then
pickup_position = { x = -pickup_position.x, y = -pickup_position.y }
drop_position = { x = -drop_position.x, y = -drop_position.y }
drop_offset = { x = -drop_offset.x, y = -drop_offset.y }
elseif direction == 1 then -- left
elseif entity.direction == defines.direction.west then
pickup_position = { x = pickup_position.y, y = -pickup_position.x }
drop_position = { x = drop_position.y, y = -drop_position.x }
drop_offset = { x = drop_offset.y, y = -drop_offset.x }
Expand Down

0 comments on commit b94ae93

Please sign in to comment.