Change dictionaries to tables (when applicable)

User avatar
_CodeGreen
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Sat Mar 05, 2022 11:30 am
Contact:

Change dictionaries to tables (when applicable)

Post by _CodeGreen »

There are a few things that are displayed as dictionaries, such as LuaEntity.belt_neighbours, but they have specific keys. ("input" and "output" here)
This trickles down to the typedefs and doesn't give autocomplete, which is technically an issue, albeit a minor one.
Some places have it already, such as LuaEntity.circuit_connected_entities, however I'm sure there are more places besides belt_neighbours that could use it.
My Mods | If you can't make it perfect, make it adjustable
Bilka
Factorio Staff
Factorio Staff
Posts: 3310
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Change dictionaries to tables (when applicable)

Post by Bilka »

Thanks for pointing this out, done for LuaEntity::belt_neighbours, LuaTrain::locomotives, LuaLogisticNetwork::get_supply_counts() and LuaLogisticNetwork::get_supply_points().

LuaEntity::neighbours was also a candidate, but I think the table type would be a mess so I left it as is. All other string dictionaries are proper dictionaries where the keys are not known beforehand.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
_CodeGreen
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Sat Mar 05, 2022 11:30 am
Contact:

Re: Change dictionaries to tables (when applicable)

Post by _CodeGreen »

Just realized I never responded, awesome and thanks!

I've noticed another place that just has string instead of a string union, which is a slightly different issue but has the same effect:
LuaItemStack::get_mapper() and set_mapper()
I couldn't find any other instances of parameters that should be string unions, but there could be elsewhere.

Speaking of set_mapper(), it doesn't have quotation marks on type's description, but I suppose that would be fixed with the above anyway.
Edit 2: set_mapper() actually has a separate problem where UpgradeFilter isn't marked as optional, yet the description says it can be nil to remove the upgrade filter.

Edit: I guess this isn't as bad as the string dictionaries, because the allowed values are almost always shown in the description, which ends up in the language server tooltip. Not in the autocomplete list, but also not really the end of the world.

Edit 3: I've decided to make new posts since this one has been marked as resolved.
Use string unions instead of generic string
LuaItemStack::set_mapper() needs optional parameter
My Mods | If you can't make it perfect, make it adjustable
Post Reply

Return to “Resolved Requests”