Page 1 of 1
[0.15 API] item-request-proxy modules is not SimpleItemStack
Posted: Tue May 16, 2017 9:54 pm
by mickael9
LuaEntity::create_entity documentation states that the modules property is an array of SimpleItemStack.
This is not true because the module format is { item = 'name', count = 42 } rather than { name = 'name', count = 42 }
I personally think that this should be replaced with a item_requests property with the same format as LuaEntity::item_requests for consistency (which could also be accepted for entity-ghost)
Re: [0.15 API] item-request-proxy modules is not SimpleItemStack
Posted: Wed May 17, 2017 12:49 am
by Rseding91
Thanks for the report. I've changed the docs to match the LuaEntity version (since that's what it is).
The LuaEntity version already does work on ghosts by the way.
Re: [0.15 API] item-request-proxy modules is not SimpleItemStack
Posted: Thu May 18, 2017 5:46 pm
by mickael9
I think there has been some misunderstanding because I just tested and Factorio 0.15.12 only accepts the old format and the docs are even more incorrect.
Let me sum it up. This is what the game accepts in
both 0.15.11 and 0.15.12:
- surface.create_entity{ name = "item-request-proxy", modules = { { item = "iron-plate", count = 10 } } }
Note this is NOT an array of SimpleItemStack which would be { { name = "iron-plate", count = 10 } }
- entity.item_requests = { ["iron-plate"] = 10 }
Where entity is of either item-request-proxy or entity-ghost type
The original problem with the docs was that it stated that
LuaSurface::create_entity accepted an array of
SimpleItemStack (which isn't true because of the
item vs
name key mismatch)
My proposal is to change what
LuaSurface::create_entity accepts (and the docs) so that the awkward
modules = { { item = "iron-plate", ... } } is replaced with
item_requests = { ["iron-plate"] = ... } which makes sense since that's the format it's eventually converted to in
LuaEntity::item_requests.
Since this would be a breaking change, I figured we might as well rename it to
item_requests for consistency's sake (because it isn't only for modules) and also accept it in
LuaSurface::create_entity for
entity-ghost entities, again for consistency.
In 0.15.12, the docs say
LuaSurface::create_entity accepts
modules = { ["iron-plate"] = 10 } which is false (it stills requires the old format, which isn't an array of
SimpleItemStack either)
Re: [0.15 API] item-request-proxy modules is not SimpleItemStack
Posted: Thu May 18, 2017 7:03 pm
by Rseding91
Ah yes... I miss-read what the code was doing (even though I wrote it)
I'll change it for the next version of 0.15 so they all work similar to the luaentity version + make the create_entity one support the old format as to not break backwards compatibility.
Re: [0.15 API] item-request-proxy modules is not SimpleItemStack
Posted: Tue May 23, 2017 8:39 pm
by mickael9
The description should be updated as well, it's outdated now:
modules :: dictionary string → uint: The stacks of items to be delivered to target entity from logistic network. Each stack must be table. If empty, the item request proxy won't be created.
How about:
modules :: dictionary string → uint: The items to be delivered to target entity from logistic network. If empty, the item request proxy won't be created.