• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

3012484

Recruit
50 Badges
Oct 27, 2012
5
0
  • Cities in Motion 2
  • Victoria 2: Heart of Darkness
  • Victoria 2: A House Divided
  • Semper Fi
  • Victoria: Revolutions
  • Europa Universalis IV: Res Publica
  • Heir to the Throne
  • Hearts of Iron III: Their Finest Hour
  • Hearts of Iron III
  • For the Motherland
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV
  • Europa Universalis III Complete
  • Cities in Motion
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Divine Wind
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis III
  • Europa Universalis III: Chronicles
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Colonel
  • Hearts of Iron IV: Field Marshal
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Hearts of Iron IV: Death or Dishonor
  • Stellaris: Synthetic Dawn
  • Cities: Skylines - Green Cities
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Expansion Pass
  • Cities: Skylines - Parklife
  • Hearts of Iron IV Sign-up
  • Stellaris
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Crusader Kings II: Horse Lords
  • Crusader Kings II: Way of Life
  • 500k Club
  • Victoria 2
  • Europa Universalis III Complete
  • Europa Universalis III Complete
  • Cities: Skylines
All,

I'm fairly advanced in creating a mod to automate trade. However, I'm stuck at 3 places:

ISSUE #1: Mod needs to cancel a trade route when certain conditions are met

- AI can cancel a route; likely though built-in function TradeRoute.Cancel
- Never figured out "how" to call a function from an event -OR-
- Cancel the route through an event / command
- There a create_trade_route; but there doesn't seem to be a cancel_trade_route
- I must have played with options / alternatives for hours AND looked at countless of examples; to no avail

Hopefully, I can add something prior to / inside / after the following to get the appropriate routes, then cancel

Code:
every_trade_route = {
    limit = {
        goods = g:paper
        exporter.owner = root
        # placeholder for other limits
    }
    
    ***is something here can be added to cancel the route***
    
}


ISSUE #2: Mod needs to adjust level of a trade route when certain conditions are met

- Routes grow and shrink automatically: I want the mod to adjust the level
- Same than above, there seems to be a built-in function called TradeRoute.Level

(same sample code than above)
Code:
every_trade_route = {
    limit = {
        goods = g:paper
        exporter.owner = root
        # placeholder for other limits
    }
    
    ***is something here can be added to change the level of the route***
    
}


ISSUE #3: Variable not recognized when creating a route

- This is likely an obvious solution to most, but my skillset is limited
- For some reason, I cannot have the create_trade_route event recognize my level variable
- Everything works when I'm using a variable for the market; the direction or the goods
- Can't figure out why the level doesn't work.... VIC3 recognizes the route as Level 1; always

Code:
set_variable = {
    name = level_test
    value = 2
}
                
create_trade_route = {
    goods = paper
    level = var:level_test   <==== creates a route at level 1; always
    direction = import
    target = c:PAP.market
}

Any help would be greatly appreciated as the trade is killing the fun for me. I feel like I'm working: opening new routes; cancelling new routes; reopening new routes; and so on.

S
 
Hey, I've messed with trade routes too and can shed a bit of light here.
Issue #1 -> Doesn't seem to be any convenient way to do it. You CAN set it to level 1, or disable it by banning the good in question or creating an embargo (but these have bad side effects). Probably the best way to go is to have the initiator change markets (by leaving/joining customs union) and immediately return (by joining/leaving customs union) to kill ALL trade routes, and then reestablish the trade routes you didn't want to delete?

Issue #2 -> Actually easy to do. Just attempt to create a new trade route with the desired level --> the old route's level will be overwritten by the new route's level

Issue #3 -> I presume that the effect just isn't coded to accepting a variable for a level. Since the trade route level is a positive integer between 1 and 100 (or higher, it seems like you can set it higher than the game allows regular trade routes to expand to), you could maybe as a workaround set up a bunch of if-else checks or a switch to create a level 1 route if the var has value 1, create a level 2 route if the var has value 2, etc.