How to prevent a player from dropping items over a transport belt?

Place to get help with not working mods / modding interface.
Post Reply
PhilBeaudoin
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Jan 19, 2019 2:33 am
Contact:

How to prevent a player from dropping items over a transport belt?

Post by PhilBeaudoin »

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:

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)
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?

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: How to prevent a player from dropping items over a transport belt?

Post by Nexela »

Use the permissions system to disable dropping items?
defines.input_action.drop_item

PhilBeaudoin
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Jan 19, 2019 2:33 am
Contact:

Re: How to prevent a player from dropping items over a transport belt?

Post by PhilBeaudoin »

Thanks! For some reason I missed this permission system. Works perfectly and makes my life much easier.

Still probably worth looking into why the event is not fired when dropping on a transport belt.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: How to prevent a player from dropping items over a transport belt?

Post by Nexela »

PhilBeaudoin wrote:
Sat Jan 19, 2019 9:26 pm
Still probably worth looking into why the event is not fired when dropping on a transport belt.
That is by design and has to do with happens to an item that is put on a transport belt

Post Reply

Return to “Modding help”