on_picked_up_item event / event when player holds an item

Place to get help with not working mods / modding interface.
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

on_picked_up_item event / event when player holds an item

Post by binbinhfr »

Is it supposed to work when you take any item in your hand ?

Because I write this :

Code: Select all

script.on_event(defines.events.on_picked_up_item, 
	function(event)
		picked = picked+1
		
		local stack = event.item_stack
		local player = game.get_player(event.player_index)
		debug( "pick " .. stack.name )
	end
)
and it does not seem to fire at all, eitehr with items from my mods on any other object I take in my hand... Do I miss something ?
My mods on the Factorio Mod Portal :geek:
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [0.12.22] on_picked_up_item event not firing on belted items

Post by daniel34 »

binbinhfr wrote:Is it supposed to work when you take any item in your hand ?
It is supposed to fire when a player picks up an item from the ground (or a belt) using the F key.
Which I just tested and it works fine.
quick links: log file | graphical issues | wiki
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Re: [0.12.22] on_picked_up_item event not firing on belted items

Post by binbinhfr »

daniel34 wrote:
binbinhfr wrote:Is it supposed to work when you take any item in your hand ?
It is supposed to fire when a player picks up an item from the ground (or a belt) using the F key.
Which I just tested and it works fine.
Oh sorry, english misunderstanding : I thought this event was fired when the player holds something in his hand.
Is an event fired in this case ? Or should I check repetively every player.cursor_stack ?
My mods on the Factorio Mod Portal :geek:
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [0.12.22] on_picked_up_item event not firing on belted items

Post by daniel34 »

binbinhfr wrote:Oh sorry, english misunderstanding : I thought this event was fired when the player holds something in his hand.
Is an event fired in this case ? Or should I check repetively every player.cursor_stack ?
I don't know, but I've split this part from the resolved bug report and into a new topic in Modding help.
quick links: log file | graphical issues | wiki
Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: [0.12.22] on_picked_up_item event not firing on belted items

Post by Supercheese »

binbinhfr wrote:
daniel34 wrote:
binbinhfr wrote:Is it supposed to work when you take any item in your hand ?
It is supposed to fire when a player picks up an item from the ground (or a belt) using the F key.
Which I just tested and it works fine.
Oh sorry, english misunderstanding : I thought this event was fired when the player holds something in his hand.
Is an event fired in this case ? Or should I check repetively every player.cursor_stack ?
Yes, you will have to check the cursor stack every so often. My Ion Cannon mod does this, you can check it out: viewtopic.php?f=93&t=17910
Post Reply

Return to “Modding help”