mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-30 23:17:53 +02:00
inserter_drops_pickup player must have inventory
event may error if player does not have an inventory
This commit is contained in:
parent
a2bac17e91
commit
f088fd215c
@ -1,4 +1,9 @@
|
||||
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
|
||||
@ -6,6 +11,9 @@ Event.add(defines.events.on_player_mined_entity, function(event)
|
||||
|
||||
local item_entity = inserter.surface.find_entity("item-on-ground", inserter.drop_position)
|
||||
if item_entity then
|
||||
game.get_player(event.player_index).mine_entity(item_entity)
|
||||
local player = game.get_player(event.player_index)
|
||||
if controllers_with_inventory[player.controller_type] then
|
||||
player.mine_entity(item_entity)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user