Page 1 of 1

Add LuaItemStack.direction

Posted: Mon May 01, 2017 1:53 am
by mickael9
I would like having the possibility to obtain (and why not change) the direction of an entity/blueprint when it's ready to be placed by the player.

I only need it in on_put_item so adding a direction key to on_put_item event arguments would work as well, I guess it's good idea to have this too.

Re: Add LuaItemStack.direction

Posted: Mon May 01, 2017 3:59 am
by Rseding91
The direction something is going to be built is not part of the game state until after the player has built the thing. At that point you get the event and it's already done.

Re: Add LuaItemStack.direction

Posted: Mon May 01, 2017 5:02 am
by mickael9
Well, I don't see a reason why the direction couldn't be added into the game state.

When on_put_item is called, the entity is not yet created and its creation can even be cancelled by, e.g, doing player.clean_cursor()
This indicates that, the information that an item is being built was indeed added to the game state (along with the item position) and before the corresponding entity was created

So I would think that adding the direction along with the position should be trivial, no?

Re: Add LuaItemStack.direction

Posted: Wed Jul 26, 2017 7:28 am
by d3x0r
The direction the item is going to be placed is known because the game is showing the direction. Having it be part of the current stack; or having some other method to get it would be quite handy... Or... Know if the entity has been shift-placed in on_built_entity... the on-shift placed item is not a ghost so none of the ghost_ values on the luaEntity work.
Edit : I see; it is; the created_entity.name is 'ghost-entity' I didn't check and assumed it would be the same as event.item as a name.