1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-30 23:17:53 +02:00

Merge pull request #161 from jacobwatkinsgit/develop

new module inserter_drops_pickup
This commit is contained in:
Gerkiz 2021-11-09 23:25:13 +01:00 committed by GitHub
commit a285dca300
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -24,6 +24,7 @@ require 'antigrief'
require 'modules.corpse_markers'
require 'modules.floaty_chat'
require 'modules.show_inventory'
require 'modules.inserter_drops_pickup'
require 'utils.debug.command'
require 'comfy_panel.main'

View File

@ -0,0 +1,19 @@
local Event = require 'utils.event'
local controllers_with_inventory = {
[defines.controllers.character] = true,
[defines.controllers.god] = true,
[defines.controllers.editor] = true,
}
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
local player = game.get_player(event.player_index)
if controllers_with_inventory[player.controller_type] then
player.mine_entity(item_entity)
end
end
end)