Sid Meier's Civilization VI

Sid Meier's Civilization VI

Map Search Extension
Sheepdog 2021 年 4 月 30 日 上午 5:05
Fix for playing with heroes mode enabled
I was getting issues trying to search for things and tracked down the issue.
If the mod has a github repo or anything I'd be happy to open a PR for the author to look at, but for now I'll just post my fix here.

The localisation is failing inside My Games\Sid Meier's Civilization VI (Epic)\Mods\Map Search Extension\MapSearchPanelExtended.lua

Adding this line:

["GREATWORKOBJECT_HERO"] = "LOC_GREATWORKOBJECT_HERO",

To GreatWorkTypeNameMap (around line 66) fixes the issue.


To prevent further issues popping up in the future I'd recommend modifying AddLocalizedSearchTerm on line 1306 from:
local AddLocalizedSearchTerm = function(kLocKey)
-- TODO try caching localized strings
table.insert( pSearchTerms, Locale.Lookup(kLocKey) );
end
To:
local AddLocalizedSearchTerm = function(kLocKey)
-- TODO try caching localized strings
if (kLocKey == nil) then
print('kLocKey was nil')
print(debug.traceback())
return
end
table.insert( pSearchTerms, Locale.Lookup(kLocKey) );
end


Additionally if you want to be able to search for great works by type (for example: Sculpture) then you can change the loop on line 453 from:
for kGreatWorkType,kGreatWorkList in pairs(kGreatWorkTable) do
AddLocalizedSearchTerm( GreatWorkTypeNameMap[kGreatWorkType] );
for _,szWorkName in pairs(kGreatWorkList) do
AddLocalizedSearchTerm( szWorkName );
end
end
to:
for kGreatWorkType,kGreatWorkList in pairs(kGreatWorkTable) do
typeNameMap = GreatWorkTypeNameMap[kGreatWorkType]
if (typeNameMap == nil) then
print("Unknown kGreatWorkType:" .. kGreatWorkType)
else
AddLocalizedSearchTerm( typeNameMap );
for _,szWorkName in pairs(kGreatWorkList) do
AddLocalizedSearchTerm( szWorkName );
end
end
end

I did this then modified MapSearchPanel.xml and MseQuickResources.lua to list great works as extra resources to select from too which was neat but too much to cover here :p
< >
正在显示第 1 - 3 条,共 3 条留言
Sheepdog 2021 年 4 月 30 日 上午 8:21 
Ley lines were also missing from ResourceClassNameMap around line 50:

["RESOURCECLASS_LEY_LINE"] = "LOC_TOOLTIP_LEY_LINE_RESOURCE"
Zur13  [开发者] 2021 年 5 月 1 日 上午 5:10 
Thanks for the notification. I've just go through the base game file and moved the changes the devs made into the mod. The devs have the bad habit to change the base game files making modders life harder. It's hard to track such changes especially when you have no free time and a many mods to support :steamsad:

P.S. Localization fix it was my mistake I've add the very same fix in base game function but forgot to add it into the XP2 function. And the devs have added similar fix into the base game files ad well.

P.P.S. Can't find anywhere in the base game or DLC the fix for GREATWORKOBJECT_HERO is it custom code made by you?

I will release fix soon.
Sheepdog 2021 年 5 月 4 日 上午 3:32 
All the changes I posted were things I did.
I was trying out mods for the first time and saw the search wasn't working for me so figured I'd dig into the logs and mod files and see if I could fix it (so there could definitely be better solutions).

Looking into the tracebacks in the log I could see there were nil indexes into the localisation function, adding some logging showed it was GREATWORKOBJECT_HERO.

Searching through the DLC folder for GREATWORKOBJECT_HERO I found this line in:
DLC/Babylon/Data/Babylon_Heroes_MODE.xml

<Row GreatWorkObjectType="GREATWORKOBJECT_HERO" Value="8" PseudoYieldType="PSEUDOYIELD_GREATWORK_ARTIFACT" Name="LOC_GREATWORKOBJECT_HERO" IconString="[ICON_GreatWork_HeroRelic]"/>

So I tried LOC_GREATWORKOBJECT_HERO for the string value and found it worked and I could search for the heroic relics (the string has the icon at the start too but I figured that was fine - better than it not working in any case!)
< >
正在显示第 1 - 3 条,共 3 条留言
每页显示数: 1530 50