Better Trade Screen

Better Trade Screen - Gathering Storm update released! 4.4

@astog use this mod when you load a game, you must restart choice repeat route, if not , it will stop when route finish

If this is true, there's an example in one of the scenario luas of saving additional data for loading games. Might be useful.
 
@astog use this mod when you load a game, you must restart choice repeat route, if not , it will stop when route finish
I fixed this in an upcoming update (will probably be ready this weekend).
 
So i installed version 3.0(have 0 mods that interfere with trading or intarface like quick ui) started a game yesterday and after I got a trader I couldn't send him anywhere, tab menu isn't working at all, after I click it - nothing happens, F4 doesn't work either, than I tried to use a version 2.1 - same problem.
Please help me fix this, cause I can't disable mod(game won't load), but playing without trading is suicide.
Game version 1.0.0.38 and changing local blockPanelInBetweenTurns = false didn't help.
 
my routes never seem to repeat they keep asking me for destination even if i select repeat route
 
So i installed version 3.0(have 0 mods that interfere with trading or intarface like quick ui) started a game yesterday and after I got a trader I couldn't send him anywhere, tab menu isn't working at all, after I click it - nothing happens, F4 doesn't work either, than I tried to use a version 2.1 - same problem.
Please help me fix this, cause I can't disable mod(game won't load), but playing without trading is suicide.
Game version 1.0.0.38 and changing local blockPanelInBetweenTurns = false didn't help.

I have the same problem.
I have a suspicion that it happens because invalid characters somewhere in the folder's path. Can you confirm it? In my case, my windows username is in Hebrew.
 
I have the same problem.
I have a suspicion that it happens because invalid characters somewhere in the folder's path. Can you confirm it? In my case, my windows username is in Hebrew.
Username is English and path to mods and game is English too.
 
I'm also having a problem of the view trades button not working. When I click it nothing happens. The trade screen worked just fine before in the same game session, but then all of a sudden stopped working. I'm fairly certain it stopped working right as one of my trade routes became invalid because the destination city (a city state) was captured by an AI. I tried saving, exiting, and reloading and the trade menu is still broken.
 
This is the exception I'm getting in the logs:
TradeOverview: Better Trade Screen loaded
TradeOverview: Retrieving previous routes PlayerConfig database
Runtime Error: C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:2195: attempt to index a nil value
stack traceback:
C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:2195: in function 'GetTradeRouteString'
C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:1460: in function 'CheckConsistencyWithMyRunningRoutes'
C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:1493: in function 'LoadRunningRoutesInfo'
C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:3041: in function 'Initialize'
C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:3123: in function '(main chunk)'
[C]: in function '(anonymous)'
Lua callstack:
Runtime Error: Error loading C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua.
stack traceback:
[C]: in function '(anonymous)'
 
I found the bug and fixed it.

There's a bug in TradeOverview.lua GetTradeRouteString (lines 2187-2197):
Code:
-- Returns a string of the route in format "[ORIGIN_CITY_NAME]-[DESTINATION_CITY_NAME]"
function GetTradeRouteString( routeInfo:table )
    local originPlayer:table = Players[routeInfo.OriginCityPlayer];
    local originCity:table = originPlayer:GetCities():FindID(routeInfo.OriginCityID);

    local destinationPlayer:table = Players[routeInfo.DestinationCityPlayer];
    local destinationCity:table = destinationPlayer:GetCities():FindID(routeInfo.DestinationCityID);


    local s:string = Locale.Lookup(originCity:GetName()) .. "-" .. Locale.Lookup(destinationCity:GetName())
    return s;
end

What happened in my case is the owner of the destination city changed so the lookup of the destinationCity based on the expected destinationPlayer resulted in a Nil value.

I was able to fix this with a simple Nil check (though simple is relative, I had never even heard of the Lua language until now):
Code:
-- Returns a string of the route in format "[ORIGIN_CITY_NAME]-[DESTINATION_CITY_NAME]"
function GetTradeRouteString( routeInfo:table )
    local originPlayer:table = Players[routeInfo.OriginCityPlayer];
    local originCity:table = originPlayer:GetCities():FindID(routeInfo.OriginCityID);

    local destinationPlayer:table = Players[routeInfo.DestinationCityPlayer];
    local destinationCity:table = destinationPlayer:GetCities():FindID(routeInfo.DestinationCityID);

    local originCityName:string = "null";
    if originCity ~= nil then
        originCityName = Locale.Lookup(originCity:GetName());
    end

    local destinationCityName:string = "null";
    if destinationCity ~= nil then
        destinationCityName = Locale.Lookup(destinationCity:GetName());
    end

    local s:string = originCityName .. "-" .. destinationCityName;
    return s;
end

Surprisingly, this worked brilliantly. The code calling this method was cleanup logic, so the existing logic was able to detect the trade route was no longer valid and removed it. Now my Trade Screen loads again and has my current routes listed!!!! I'm so happy. :)

These are the new logs I see after making the above change:
TradeOverview: Better Trade Screen loaded
TradeOverview: Retrieving previous routes PlayerConfig database
TradeOverview: Route Ostia-null is no longer running. Removing it.
TradeOverview: Route Aquileia-null is no longer running. Removing it.
TradeOverview: Route Arretium-Mohenjo-Daro is no longer running. Removing it.
TradeOverview: Route Aquileia-Changsha is no longer running. Removing it.
TradeOverview: Route Ostia-Pazyryk is no longer running. Removing it.
TradeOverview: Dumping routes in PlayerConfig database
 
Last edited:
This is the exception I'm getting in the logs:
TradeOverview: Better Trade Screen loaded
TradeOverview: Retrieving previous routes PlayerConfig database
Runtime Error: C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:2195: attempt to index a nil value
stack traceback:
C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:2195: in function 'GetTradeRouteString'
C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:1460: in function 'CheckConsistencyWithMyRunningRoutes'
C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:1493: in function 'LoadRunningRoutesInfo'
C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:3041: in function 'Initialize'
C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua:3123: in function '(main chunk)'
[C]: in function '(anonymous)'
Lua callstack:
Runtime Error: Error loading C:\Users\Kyle\Documents\My Games\Sid Meier's Civilization VI\Mods\Better Trade Screen\UI\TradeOverview.lua.
stack traceback:
[C]: in function '(anonymous)'

I found the bug and fixed it.

There's a bug in TradeOverview.lua GetTradeRouteString (lines 2187-2197):
Code:
-- Returns a string of the route in format "[ORIGIN_CITY_NAME]-[DESTINATION_CITY_NAME]"
function GetTradeRouteString( routeInfo:table )
    local originPlayer:table = Players[routeInfo.OriginCityPlayer];
    local originCity:table = originPlayer:GetCities():FindID(routeInfo.OriginCityID);

    local destinationPlayer:table = Players[routeInfo.DestinationCityPlayer];
    local destinationCity:table = destinationPlayer:GetCities():FindID(routeInfo.DestinationCityID);


    local s:string = Locale.Lookup(originCity:GetName()) .. "-" .. Locale.Lookup(destinationCity:GetName())
    return s;
end

What happened in my case is the owner of the destination city changed so the lookup of the destinationCity based on the expected destinationPlayer resulted in a Nil value.

I was able to fix this with a simple Nil check (though simple is relative, I had never even heard of the Lua language until now):
Code:
-- Returns a string of the route in format "[ORIGIN_CITY_NAME]-[DESTINATION_CITY_NAME]"
function GetTradeRouteString( routeInfo:table )
    local originPlayer:table = Players[routeInfo.OriginCityPlayer];
    local originCity:table = originPlayer:GetCities():FindID(routeInfo.OriginCityID);

    local destinationPlayer:table = Players[routeInfo.DestinationCityPlayer];
    local destinationCity:table = destinationPlayer:GetCities():FindID(routeInfo.DestinationCityID);

    local originCityName:string = "null";
    if originCity ~= nil then
        originCityName = Locale.Lookup(originCity:GetName());
    end

    local destinationCityName:string = "null";
    if destinationCity ~= nil then
        destinationCityName = Locale.Lookup(destinationCity:GetName());
    end

    local s:string = originCityName .. "-" .. destinationCityName;
    return s;
end

Surprisingly, this worked brilliantly. The code calling this method was cleanup logic, so the existing logic was able to detect the trade route was no longer valid and removed it. Now my Trade Screen loads again and has my current routes listed!!!! I'm so happy. :)

These are the new logs I see after making the above change:
TradeOverview: Better Trade Screen loaded
TradeOverview: Retrieving previous routes PlayerConfig database
TradeOverview: Route Ostia-null is no longer running. Removing it.
TradeOverview: Route Aquileia-null is no longer running. Removing it.
TradeOverview: Route Arretium-Mohenjo-Daro is no longer running. Removing it.
TradeOverview: Route Aquileia-Changsha is no longer running. Removing it.
TradeOverview: Route Ostia-Pazyryk is no longer running. Removing it.
TradeOverview: Dumping routes in PlayerConfig database

This is why I love modding.

I guess this bug happens when a city changes hands, and that particular city is no longer tied to that player. That would explain nil elements being passed. Anyways, great job figuring that one out. I will add this fix to the upcoming update.
 
Suggestions:
Sort cities alphabetically in the "select trade route destination" list.
When you select a city in the "select trade route destination" list , show trade route only to that city.
When you have a trader selected, show its current trade route.
 
It does not work, follow the instructions on ustanvki. No results. What to do?
 
It does not work, follow the instructions on ustanvki. No results. What to do?
Try installing the mod into the DLC folder. For some users this seems to fix it.
 
Is there a reason why AVG detects this, TradeOverview.lua, to be a "Trojan horse"?

"Linux/Agent Lua is a malicious application that allows hackers to remotely access your computer system letting them modify files, steal personal information and install more unwanted software. These kinds of threats, called Trojan horse, must be sent to you by someone or carried by another program. They may also arrive thanks to unwanted downloads on infected websites or installed with online games or other internet-driven applications. Most Trojan horses can be detected and removed by AVG."
 
Last edited:
Is there a reason why AVG detects this, TradeOverview.lua, to be a "Trojan horse"?

"Linux/Agent Lua is a malicious application that allows hackers to remotely access your computer system letting them modify files, steal personal information and install more unwanted software. These kinds of threats, called Trojan horse, must be sent to you by someone or carried by another program. They may also arrive thanks to unwanted downloads on infected websites or installed with online games or other internet-driven applications. Most Trojan horses can be detected and removed by AVG."
False positive. Your AVG is drunk
 
Is there a reason why AVG detects this, TradeOverview.lua, to be a "Trojan horse"?

"Linux/Agent Lua is a malicious application that allows hackers to remotely access your computer system letting them modify files, steal personal information and install more unwanted software. These kinds of threats, called Trojan horse, must be sent to you by someone or carried by another program. They may also arrive thanks to unwanted downloads on infected websites or installed with online games or other internet-driven applications. Most Trojan horses can be detected and removed by AVG."
I also use AVG and have not encountered that.
 
Back
Top Bottom