Writable LuaEntity:held_stack_position

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
sparr
Smart Inserter
Smart Inserter
Posts: 1573
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Writable LuaEntity:held_stack_position

Post 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.
Last edited by sparr on Sun May 07, 2017 6:02 pm, edited 1 time in total.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Writable LuaEntity:held_stack and held_stack_position

Post by Nexela »

held_stack is an inventory stack so doing this will work inserter.held_stack.set_stack({name=item, count=1})
Last edited by Nexela on Sun May 07, 2017 6:12 pm, edited 1 time in total.
sparr
Smart Inserter
Smart Inserter
Posts: 1573
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: Writable LuaEntity:held_stack_position

Post by sparr »

Thanks. It is a LuaItemStack and you seem to be right! Halfway there!
sparr
Smart Inserter
Smart Inserter
Posts: 1573
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: Writable LuaEntity:held_stack_position

Post 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.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4941
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Writable LuaEntity:held_stack_position

Post 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.
Post Reply

Return to “Modding interface requests”