Page 1 of 1

on_picked_up_item event / event when player holds an item

Posted: Tue Apr 19, 2016 2:31 pm
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 ?

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

Posted: Tue Apr 19, 2016 2:39 pm
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.

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

Posted: Tue Apr 19, 2016 2:45 pm
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 ?

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

Posted: Tue Apr 19, 2016 3:34 pm
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.

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

Posted: Tue Apr 19, 2016 9:12 pm
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