2021-11-09 04:58:32 +02:00
|
|
|
local Event = require 'utils.event'
|
2021-11-09 07:28:49 +02:00
|
|
|
local controllers_with_inventory = {
|
|
|
|
[defines.controllers.character] = true,
|
|
|
|
[defines.controllers.god] = true,
|
|
|
|
[defines.controllers.editor] = true,
|
|
|
|
}
|
2021-11-09 04:58:32 +02:00
|
|
|
|
|
|
|
Event.add(defines.events.on_player_mined_entity, function(event)
|
|
|
|
local inserter = event.entity
|
|
|
|
if (not inserter.valid) or (inserter.type ~= "inserter") or inserter.drop_target then return end
|
|
|
|
|
|
|
|
local item_entity = inserter.surface.find_entity("item-on-ground", inserter.drop_position)
|
|
|
|
if item_entity then
|
2021-11-09 07:28:49 +02:00
|
|
|
local player = game.get_player(event.player_index)
|
|
|
|
if controllers_with_inventory[player.controller_type] then
|
|
|
|
player.mine_entity(item_entity)
|
|
|
|
end
|
2021-11-09 04:58:32 +02:00
|
|
|
end
|
|
|
|
end)
|