How to prevent a player from dropping items over a transport belt?
Posted: Sat Jan 19, 2019 2:40 am
Hi!
I've building a mod where I need to prevent a player from dropping items on the ground with the "Z" keystroke. The mod uses the god-controller so I cannot use set the drop_item_distance = 0 in the prototype.
This piece of code works most of the time:
However, when the player uses "Z" over a transport belt, the event doesn't seem to get triggered. Any idea if there is a way to get notified in this case?
I've building a mod where I need to prevent a player from dropping items on the ground with the "Z" keystroke. The mod uses the god-controller so I cannot use set the drop_item_distance = 0 in the prototype.
This piece of code works most of the time:
Code: Select all
script.on_event(defines.events.on_player_dropped_item, function(e)
-- Dropping is not allowed.
local player = game.players[e.player_index]
local item_on_ground = e.entity
add_item_to_cursor_quickbar_or_inventory(player, item_on_ground.stack.name, item_on_ground.stack.count)
item_on_ground.destroy()
end)