Page 1 of 1
Change dictionaries to tables (when applicable)
Posted: Fri Dec 01, 2023 5:25 am
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.
Re: Change dictionaries to tables (when applicable)
Posted: Mon Dec 11, 2023 3:14 pm
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.
Re: Change dictionaries to tables (when applicable)
Posted: Wed Dec 27, 2023 10:47 am
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