STR_INDUSTRY_COLOR_BLUE : {BLUE}{STRING}
STR_INDUSTRY_FARM : Farm
STR_INDUSTRY_BANK : Bank
STR_INDUSTRY_NOMATCH : Unknown
Like planetmaker said use the industry type name. And use the good STR_INDUSTRY_ for your output.
local z = GSText(GSText.STR_INDUSTRY_COLOR_BLUE);
local match = false;
if (GSIndustry.GetName = "farm name") { match = true; z.AddParam(GSText(GSText.STR_INDUSTRY_FARM)); }
if (GSIndustry.GetName = "bank name") { match = true; z.AddParam(GSText(GSText.STR_INDUSTRY_BANK)); }
if (!match) { z.AddParam(GSText(GSText.STR_INDUSTRY_NOMATCH); }
I didn't check the return value of the GetName function, but if you want an even more generic function you can lookup the GSText class to find if the return value from a function match an existing string in it: (i'm sure you want a sample ?)
Code: Select all
local cargolist = GSCargoList();
foreach (cargo, _ in cargolist)
{
local k = GSCargo.GetCargoLabel(cargo);
foreach (key, _ in GSText)
{
local output = null;
local cargotext = null;
if (key.find("STR_CARGOTYPE_"+k) != null) { cargotext = GSText(GSText["STR_CARGOTYPE_"+k]); }
if (cargotype == null) { output = GSText(GSText.STR_CARGOTYPE_NOTFOUND; }
else { output = GSText(GSText.STR_CARGOTYPE_FOUND, cargotext); }
}
}
and an english.txt with
STR_CARGOTYPE_FOUND : {GREEN}{STRING}
STR_CARGOTYPE_NOTFOUND: {RED}Not found in english.txt
STR_CARGOTYPE_COAL : Coal cargo