Page 1 of 1

[1.1.6] Spidertron item grid is not recognised

Posted: Thu Dec 17, 2020 2:15 am
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.

Re: [1.1.6] Spidertron item grid is not recognised

Posted: Thu Dec 17, 2020 6:06 pm
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.

Re: [1.1.6] Spidertron item grid is not recognised

Posted: Sun Dec 20, 2020 1:57 am
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.

Re: [1.1.6] Spidertron item grid is not recognised

Posted: Wed Jan 06, 2021 11:41 pm
by Rseding91
Ok, I added LuaItemStack::create_grid() for the next release.