Skip to content

Commit

Permalink
Updating Adjustable Inserters mod for 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KiwiHawk committed Oct 23, 2024
1 parent 040ecdc commit 72146e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
37 changes: 20 additions & 17 deletions bobinserters/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function gui_add_title(gui, title, button_name, drag_target)
type = "sprite-button",
name = button_name,
style = "frame_action_button",
sprite = "utility/close_white",
sprite = "utility/close",
})
if drag_target then
gui.title_flow.title.drag_target = gui
Expand Down Expand Up @@ -393,7 +393,7 @@ script.on_event("bob-inserter-pickup-rotate", function(event)
local entity = player.selected
if
entity
and entity.type == "inserter"
and (entity.type == "inserter" or (entity.type == "entity-ghost" and entity.ghost_type == "inserter"))
and player.can_reach_entity(entity)
and not storage.bobmods.inserters.blacklist[entity.name]
then
Expand All @@ -406,7 +406,7 @@ script.on_event("bob-inserter-drop-rotate", function(event)
local entity = player.selected
if
entity
and entity.type == "inserter"
and (entity.type == "inserter" or (entity.type == "entity-ghost" and entity.ghost_type == "inserter"))
and player.can_reach_entity(entity)
and not storage.bobmods.inserters.blacklist[entity.name]
then
Expand All @@ -419,7 +419,7 @@ script.on_event("bob-inserter-pickup-range", function(event)
local entity = player.selected
if
entity
and entity.type == "inserter"
and (entity.type == "inserter" or (entity.type == "entity-ghost" and entity.ghost_type == "inserter"))
and player.can_reach_entity(entity)
and not storage.bobmods.inserters.blacklist[entity.name]
then
Expand All @@ -432,7 +432,7 @@ script.on_event("bob-inserter-drop-range", function(event)
local entity = player.selected
if
entity
and entity.type == "inserter"
and (entity.type == "inserter" or (entity.type == "entity-ghost" and entity.ghost_type == "inserter"))
and player.can_reach_entity(entity)
and not storage.bobmods.inserters.blacklist[entity.name]
then
Expand All @@ -445,7 +445,7 @@ script.on_event("bob-inserter-long", function(event)
local entity = player.selected
if
entity
and entity.type == "inserter"
and (entity.type == "inserter" or (entity.type == "entity-ghost" and entity.ghost_type == "inserter"))
and player.can_reach_entity(entity)
and not storage.bobmods.inserters.blacklist[entity.name]
then
Expand All @@ -458,7 +458,7 @@ script.on_event("bob-inserter-near", function(event)
local entity = player.selected
if
entity
and entity.type == "inserter"
and (entity.type == "inserter" or (entity.type == "entity-ghost" and entity.ghost_type == "inserter"))
and player.can_reach_entity(entity)
and not storage.bobmods.inserters.blacklist[entity.name]
then
Expand All @@ -471,7 +471,7 @@ script.on_event("bob-inserter-open-gui", function(event)
local entity = player.selected
if
entity
and entity.type == "inserter"
and (entity.type == "inserter" or (entity.type == "entity-ghost" and entity.ghost_type == "inserter"))
and player.can_reach_entity(entity)
and not storage.bobmods.inserters.blacklist[entity.name]
then
Expand All @@ -484,9 +484,17 @@ end)

script.on_event(defines.events.on_gui_opened, function(event)
local player = game.players[event.player_index]
if event.gui_type == defines.gui_type.entity and event.entity and event.entity.type == "inserter" then
if event.gui_type == defines.gui_type.entity and event.entity then
local prototype
if event.entity.type == "inserter" then
prototype = event.entity.prototype
elseif event.entity.type == "entity-ghost" and event.entity.ghost_type == "inserter" then
prototype = event.entity.ghost_prototype
end

if
event.entity.prototype.allow_custom_vectors
prototype
and prototype.allow_custom_vectors
and not storage.bobmods.inserters.blacklist[event.entity.name]
and settings.get_player_settings(player)["bobmods-inserters-gui-position"].value ~= "off"
then
Expand Down Expand Up @@ -664,19 +672,14 @@ end)

script.on_event(defines.events.on_built_entity, function(event)
local player = game.players[event.player_index]
local entity = event.created_entity
local entity = event.entity

local entity_name = entity.name
if entity.type == "entity-ghost" then
entity_name = entity.ghost_name
end

if
event.item
and event.item.place_result
and event.item.place_result.type == "inserter"
and (entity.type == "inserter" or (entity.type == "entity-ghost" and entity.ghost_type == "inserter"))
and event.item.place_result.name == entity_name --probably don't even need this line anymore.
if (entity.type == "inserter" or (entity.type == "entity-ghost" and entity.ghost_type == "inserter"))
and not storage.bobmods.inserters.blacklist[entity_name]
then
bobmods.logistics.set_positions(entity, event.player_index)
Expand Down
11 changes: 3 additions & 8 deletions boblogistics/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -439,20 +439,15 @@ end)

script.on_event(defines.events.on_built_entity, function(event)
local player = game.players[event.player_index]
local entity = event.created_entity
local entity = event.entity

local entity_name = entity.name
if entity.type == "entity-ghost" then
entity_name = entity.ghost_name
end

if
not game.active_mods["bobinserters"]
and event.item
and event.item.place_result
and event.item.place_result.type == "inserter"
if not game.active_mods["bobinserters"]
and (entity.type == "inserter" or (entity.type == "entity-ghost" and entity.ghost_type == "inserter"))
and event.item.place_result.name == entity_name --probably don't even need this line anymore.
and not storage.bobmods.logistics.blacklist[entity_name]
then
bobmods.logistics.set_positions(entity, event.player_index)
Expand All @@ -475,7 +470,7 @@ script.on_event(defines.events.on_built_entity, function(event)
end)

script.on_event(defines.events.on_robot_built_entity, function(event)
local entity = event.created_entity
local entity = event.entity
if
settings.startup["bobmods-logistics-inserteroverhaul"].value == true
and entity.type == "inserter"
Expand Down

0 comments on commit 72146e8

Please sign in to comment.