Page 1 of 1
[0.12.11] [kovarex] game.get_localised_technology_name gives error
Posted: Sun Oct 18, 2015 7:43 pm
by MrDoomah
When trying to get a string using game.get_localised_technology_name, it gives an error if the technology name ends in a number (eg, automation-2).
This doesn't happen when using technologies that don't contain any number (eg automation, optics etc).
Re: [0.12.11] game.get_localised_technology_name gives error
Posted: Sun Oct 18, 2015 8:31 pm
by cartmen180
that's because those techs don't have their own string. They take theirs from their previous tier and simply add a number after it. (At least that is how i think it works)
Re: [0.12.11] game.get_localised_technology_name gives error
Posted: Sun Oct 18, 2015 10:25 pm
by bobingabout
Yeah, I agree with cartmen, if a technology ends with a -#, EG automation-2 it will display the locale entry for automation with a number after it "Automation 2" for example.
It's basically to minimise the number of locale entries required for things that usually have multiple tiers, like research. it doesn't work with entities or items, just technology.
Re: [0.12.11] game.get_localised_technology_name gives error
Posted: Mon Oct 19, 2015 8:21 am
by MrDoomah
That makes sense internally, but for an api it should still return "automation 2".
Now I need to take the technology name, strip it of its number (if any) and the dash before it, run that through the get_localised_name, and then add the number back in. Besides, as far as I know, trying to manipulate the string coming from get_localised_name results in an error an sich, stating you can't concatenate a table and string (but that's from the top of my head, but I'm 99% sure).
Re: [0.12.11] game.get_localised_technology_name gives error
Posted: Mon Oct 19, 2015 8:59 am
by bobingabout
I'm not entirely sure this is actually a bug, but I agree that if the game itself is able to parse a technology localisation string, then the command should return the same result as well, instead of an error.
Re: [0.12.11] [kovarex] game.get_localised_technology_name gives error
Posted: Mon Oct 19, 2015 1:30 pm
by kovarex
The error was in the internal code that pushes compound localisation string into lua, quite internal thing.
It is fixed for 0.12.12.
P.S. I should also update the interface, as this should be read-only propertly of LuaTechnology instead.
Re: [0.12.11] [kovarex] game.get_localised_technology_name gives error
Posted: Mon Oct 19, 2015 1:36 pm
by MrDoomah
Thumbs up to you!