Skip to content

Commit 5f5bb45

Browse files
committed
compatibility: Support interaction with Bob's Adjustable Inserters and Smart Inserters
1 parent 26aa122 commit 5f5bb45

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

script/selector.lua

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,26 @@ local function register_tick_handlers()
761761
end
762762
end
763763

764+
local register_custom_handlers = function()
765+
-- Register handlers for custom events raised by other mods when inserter drop or pickup positions are changed
766+
767+
-- Smart_Inserters 2.0.0+
768+
if remote.interfaces["Smart_Inserters"] and remote.interfaces["Smart_Inserters"]["on_inserter_arm_changed"] then
769+
script.on_event(remote.call("Smart_Inserters", "on_inserter_arm_changed"), function (event)
770+
if not event.entity or not event.entity.valid then return end
771+
notify(event.entity.unit_number)
772+
end)
773+
end
774+
775+
-- Bob's Adjustable Inserters 0.18.0+
776+
if remote.interfaces["bobinserters"] and remote.interfaces["bobinserters"]["get_changed_position_event_id"] then
777+
script.on_event(remote.call("bobinserters", "get_changed_position_event_id"), function (event)
778+
if not event.entity or not event.entity.valid then return end
779+
notify(event.entity.unit_number)
780+
end)
781+
end
782+
end
783+
764784
local library = {
765785
-- Event Handling
766786
on_init = function ()
@@ -825,8 +845,12 @@ local library = {
825845
storage.mourners = {}
826846

827847
register_tick_handlers()
848+
register_custom_handlers()
849+
end,
850+
on_load = function ()
851+
register_tick_handlers()
852+
register_custom_handlers()
828853
end,
829-
on_load = register_tick_handlers,
830854
---@type table<defines.events, function>
831855
events = {
832856
[defines.events.on_surface_cleared] = function (event)

0 commit comments

Comments
 (0)