Page 1 of 1

[1.1.107] LuaSurface.create_entity docs missing stack property

Posted: Mon Apr 15, 2024 9:00 pm
by Danielv123
Attempting to create an item-on-ground with LuaSurface.create_entity without providing the stack parameter results in an error.

https://lua-api.factorio.com/latest/cla ... ate_entity

The stack property works fine, however it is not documented that it is accepted by the function.

/c game.player.surface.create_entity{name = "item-on-ground", position = game.player.position}

Error: Key "stack" not found in property tree

/c game.player.surface.create_entity{name = "item-on-ground", position = game.player.position, stack = "blueprint"} works sucessfully. I assume it accepts a SimpleItemStack.

Re: [1.1.107] LuaSurface.create_entity docs missing stack property

Posted: Mon Apr 15, 2024 9:02 pm
by Danielv123
I see now that this is supposed to go in viewforum.php?f=233 - sorry about that

Re: [1.1.107] LuaSurface.create_entity docs missing stack property

Posted: Tue Apr 16, 2024 4:49 am
by Pi-C
Danielv123 wrote:
Mon Apr 15, 2024 9:00 pm
Attempting to create an item-on-ground with LuaSurface.create_entity without providing the stack parameter results in an error.

https://lua-api.factorio.com/latest/cla ... ate_entity

The stack property works fine, however it is not documented that it is accepted by the function.
"item-on-ground" is an "item-entity" prototype. If you look closely, right below the table "Parameters", after the sentence "Other attributes may be specified depending on the type of entity:", you'll find this note about item-entities:
Screenshot at 2024-04-16 06-27-58.png
Screenshot at 2024-04-16 06-27-58.png (216.9 KiB) Viewed 264 times
So the info already is available, but it's easy to miss the optional, type-based parameters after the first table. For example, I recently had to search the forum because I couldn't figure out how to create a character-corpse with >0 item slots. I eventually found an answer to a question about exactly the same issue that pointed out the type-specific parameters (fun fact: I've also posted the original question some years ago).

Re: [1.1.107] LuaSurface.create_entity docs missing stack property

Posted: Sat May 04, 2024 4:53 pm
by Bilka
As Pi-C notes, this already documented for the entity type, which is "item-entity", not "item-on-ground".