on_put_item What Item?

Things that already exist in the current mod API
Post Reply
matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

on_put_item What Item?

Post by matjojo »

I'd like to know what item was used when placing an entity, I think it'd be most useful for the on_put_item event, but a second would be the on_built_entity event, although that does not really have to be with an item.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13797
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_put_item What Item?

Post by Rseding91 »

The item is the item in the players cursor.
If you want to get ahold of me I'm almost always on Discord.

matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: on_put_item What Item?

Post by matjojo »

Rseding91 wrote:The item is the item in the players cursor.
Oww, so it goes about like this: On put item> on entity build> item taken from cursor?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13797
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_put_item What Item?

Post by Rseding91 »

matjojo wrote:
Rseding91 wrote:The item is the item in the players cursor.
Oww, so it goes about like this: On put item> on entity build> item taken from cursor?
yes.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: on_put_item What Item?

Post by Mooncat »

Ah, damn. I forgot the cursor stack holds the item for building the entity. (I knew it when making Creative Mode, but then forgot it when making new mods.)

Would you mind adding description about this on the doc please? :D



Edit: oh wait! I think the order above is incorrect.
It should be: on_put_item -> item taken from cursor -> on_built_entity

If the player has spent the last item, cursor stack will be invalid for read in on_built_entity. In that case, it is not possible to know which item was used to build the entity. :?

Maybe it is related as well: placed_item in on_built_entity/on_robot_built_entity

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: on_put_item What Item?

Post by bobingabout »

Well, you do have access to who built the entity, as well as the entity type. Unless you have more than one item definition to place the same entity, it shouldn't be an issue. But in that case, why would you have multiple items to place the same entity type?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: on_put_item What Item?

Post by matjojo »

bobingabout wrote:Well, you do have access to who built the entity, as well as the entity type. Unless you have more than one item definition to place the same entity, it shouldn't be an issue. But in that case, why would you have multiple items to place the same entity type?

I'm not really concerned why someone would make it so, i want my nod to work when someone does do it.

Post Reply

Return to “Already exists”