[1.1.6] Spidertron item grid is not recognised

Post Reply
User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

[1.1.6] Spidertron item grid is not recognised

Post by Earendel »

I was originally going to post this as a modding interface request but after more investigation this might actually be a bug. The behaviour is at least inconsistent.

If you have an armor item and that item has a grid, then LuaItemStack.grid will return the grid even if it is a brand new item. The armor has nothing in the grid, yet it still returns the grid so things can be added to the grid via script.

The same thing does not hold true for a spidertron. On a new item LuaItemStack.grid will return nil, even though the spidertron should have a grid. If the entity is placed, has something added to the grid, then mined again, the LuaItemStack.grid will return the grid if there is something in it.

Steps to reproduce:
With power armor in cursor:

Code: Select all

/c game.print(game.player.cursor_stack.grid) 
With spidertron in cursor:

Code: Select all

/c game.print(game.player.cursor_stack.grid) 
So it seems like a bug that the grid is not recognised from a fresh spidertron item.

If this is not a bug then I will be making an interface request instead because currently it doesn't seem possible to automate grid equipment population before vehicle deployment.

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

Re: [1.1.6] Spidertron item grid is not recognised

Post by Rseding91 »

Thanks for the report however that is intended. It works that way so things like trains can stack when first created and only become un-stackable once the grid has been populated with contents.

Moving to modding interface requests.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [1.1.6] Spidertron item grid is not recognised

Post by Earendel »

Ok thanks.

In that case I'm assuming that trying to force an existing item stack into a has_entity_data state would be a problem if the stack has a count over 1. This would make it seem like the best way to make a LuaItemStack with entity data would be by making a new item, and my guess would be that this would need to be done as a function of an inventory.

If that is the case then my request is:

Code: Select all

LuaInventory.create_item_with_entity_data{
  name = item name,
  entity = LuaEntity or table or nil (optional)
}
The entity parameter could specify an entity to copy entity data from, or a table with a limited set of common entity data values, or nil.
Returns LuaItemStack or nil if no item was created.

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

Re: [1.1.6] Spidertron item grid is not recognised

Post by Rseding91 »

Ok, I added LuaItemStack::create_grid() for the next release.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Implemented mod requests”