Page 1 of 1

Writable LuaEntity:held_stack_position

Posted: Sun May 07, 2017 5:14 pm
by sparr
I want to be able to force an item into an inserter's hand so that I don't have to make an invisible chest for it to automatically grab from.

I want to set the current position of the hand so that when I create the entities they will start with the hand in the right spot, rather than having to animate to get there.

Re: Writable LuaEntity:held_stack and held_stack_position

Posted: Sun May 07, 2017 5:45 pm
by Nexela
held_stack is an inventory stack so doing this will work inserter.held_stack.set_stack({name=item, count=1})

Re: Writable LuaEntity:held_stack_position

Posted: Sun May 07, 2017 6:03 pm
by sparr
Thanks. It is a LuaItemStack and you seem to be right! Halfway there!

Re: Writable LuaEntity:held_stack_position

Posted: Tue Sep 08, 2026 7:56 pm
by sparr
I still have a use case for this. I have a mod that constructs the ghosts near the player, and I'd like to animate inserter arms Doctor Octopus style, but I need to be able to set their hand position to get the animation right.

Re: Writable LuaEntity:held_stack_position

Posted: Tue Sep 08, 2026 8:12 pm
by boskid
This is unlikely to be implemented in the proposed form because held_stack_position is not a primary variable, it is a result of a function computed based on inserter's hand distance, hand height and head orientation. Thats 3 degrees of freedom and if a vector was given it would only provide 2 constraints which is not enough.

Hand distance and hand orientation have quite precise meaning but the hand height is an additional factor used to make inserter movement more interesting which is why held_stack_position read exists: it allows matching actual movement of inserter hand. If this write was done, it would have to change head orientation and hand distance while keeping hand height parameter fixed which may cause some miniscule artifacts about inserter behavior near ends of movement as the hand could be too high repeatably.