• 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.
The syntax should be the same that EUIV uses so I'll just quote Captain Gars post where he explains it in a thorough manner.
Do note however that I've yet to fill out most of the variables that can be exported. So please head over here https://forum.paradoxplaza.com/foru...eature-feedback-request.951329/#post-21468139 to suggest prioritized game values to export.

Update:

- Added a while effect
- Added an export_to_variable effect

Examples:

Code:
    set_variable = { which = count value = 20 }
    while = {
       limit = {
         check_variable = {
           which = count
           value = 1
         }
       }    
       subtract_variable = {
         which = count
         value = 1
       }
       add_treasury = 5
     }

Note: the while effect will not produce any tooltip due to the problems that would cause. Also, make sure you don't create an endless loop... (altough there is a fail-safe at 100K loops)

Code:
    export_to_variable = {
       which = prestigeVar
       value = prestige
     }

Note: The current country's prestige is saved in the variable.

Code:
    export_to_variable = {
       which = stabilityVar
       value = stability
       who = FROM
     }

Note: FROM's stability is saved in the variable.

Code:
    export_to_variable = {
       which = productionEfficiencyVar
       value = modifier:production_efficiency
     }

Note: The current country's modifier production_efficiency is saved in the variable.

Code:
    export_to_variable = {
       which = borderDistanceVar
       value = borderDistance
       who = FRA
     }

Note: The border distance between the current country and FRA is saved in the variable.

General note: export_to_variable also works in province scope

Country values:
Code:
prestige
war_exhaustion
manpower
manpower_percentage
max_manpower
states_development
average_autonomy
average_home_autonomy
corruption
stability
treasury
land_forcelimit
naval_forcelimit
average_unrest
num_of_cities
army_tradition
navy_tradition
mercantilism
overextension_percentage
inflation
num_of_ports
patriarch_authority
piety
religious_unity
ADM
DIP
MIL
heir_adm
heir_dip
heir_mil
tolerance_to_this
trade_income_percentage
years_of_income
monthly_income
army_size
navy_size
adm_tech
dip_tech
mil_tech
border_distance
capital_distance
+ all global modifiers

Province values:
Code:
province_trade_power
local_autonomy
base_manpower
base_production
base_tax
development
unrest
nationalism
tolerance_to_this
+ all local modifiers
 
  • 2
Reactions:
Very nice!
Just to check with regards to while, I am getting the idea it is a constantly looping if clause until the limit is no longer satisfied or you reach the fail safe value of 100K, is that correct?
 
  • 1
Reactions:
Divine, how frequently does the while loop trigger? And can we get the ability to define how frequently? Such as weekly, daily, monthly, or indeed yearly?
 
Divine, how frequently does the while loop trigger? And can we get the ability to define how frequently? Such as weekly, daily, monthly, or indeed yearly?

What do you mean? Fron the example, one would assume that the while = {} effect is executed once when called (as in, if it loops 999 times, the 999 loops are executed in one game tick, not periodically. Or am I missing something here?
 
  • 1
Reactions:
Well if all your loops are triggered in one tick then what the hell is the the point of it? If it instead is an effect triggered every tick till there is a change of conditions, it would seem it is much less likely to spiral totally out of control. Especially if for instance you use a while condition that is not going to be false for say 10-15 ticks from the start.
 
It depends actually on how you use a while loop. My point though is with CKII why would you want a while loop that did have a tick function?
 
It depends actually on how you use a while loop. My point though is with CKII why would you want a while loop that did have a tick function?
Anything you would use a while loop in programming for. For example right now I have an event that fires itself X times until a condition is met. A while loop would be a way better solution. Anything with complicated variable operations would benefit from such a loop.
 
  • 3
  • 1
Reactions:
At the moment I am using similar things, I am thinking though more of an operations standpoint, what if the condition does not become valid for x number of ticks? Depending on how fast the while loop acts it will cause a crash.
 
At the moment I am using similar things, I am thinking though more of an operations standpoint, what if the condition does not become valid for x number of ticks? Depending on how fast the while loop acts it will cause a crash.
What you seem to be wanting is better handled by repeat_event with a delay.
 
  • 1
Reactions:
Rich it is how I already do it. TBH my question with While loop is that I do not see how it will not simply cause issues.
 
You'll simply have to code keeping in mind that it will run continually until the conditions are met and make sure there aren't some edge cases that could make it run more than it should, just like what you have to do in programming languages.
 
  • 1
Reactions:
Sorry that I'm late to answer. Had a week of early vacation. Yes the while loop is implemented as an effect and will execute until the condition is no longer met. It will check the condition before every execution of the combined effects inside the loop. If you have a huge effect inside the loop and you are doing lots of loops it can cause a lag spike so it is something to keep in mind when using the while loop.
 
  • 3
Reactions:
These are the implemented game values currently available for export_to_variable effect.

Character:
martial
diplomacy
intrigue
stewardship
learning
base_health
demesne_efficiency
decadence
dynasty_realm_power
fertility
infamy
monthly_income
plot_power
population_factor
relative_power_to_liege
religion_authority
scaled_wealth
treasury
yearly_income
age
ai_ambition
ai_greed
ai_honor
ai_rationality
ai_zeal
among_most_powerful_vassals
combat_rating
demesne_garrison_size
demesne_size
health_traits
imprisoned_days
lifestyle_traits
max_manpower
num_of_baron_titles
num_of_children
num_of_claims
num_of_consorts
num_of_count_titles
num_of_count_titles_in_realm
num_of_duke_titles
num_of_dynasty_members
num_of_emperor_titles
num_of_extra_landed_titles
num_of_friends
num_of_holy_sites
num_of_king_titles
num_of_lovers
num_of_plot_backers
num_of_prisoners
num_of_rivals
num_of_subrealm_castles
num_of_subrealm_cities
num_of_spouses
num_of_titles
num_of_trade_posts
num_of_traits
num_of_unique_dynasty_vassals
num_of_vassals
over_max_demesne_size
over_vassal_limit
personality_traits
piety
population
population_and_manpower
prestige
realm_diplomacy
realm_intrigue
realm_learning
realm_martial
realm_stewardship
realm_levies
max_realm_levies
realm_size
republic_total_num_of_trade_posts
ruled_years
score
unused_manpower
retinue_points_max
retinue_points_used
retinue_points_free

Title:
mercenary_siphon_factor
num_fitting_characters_for_title
num_of_buildings
num_of_feuds
population
population_and_manpower
ruled_years
unused_manpower
holding_tax_value

Province:

religion_authority
revolt_risk
num_of_empty_holdings
num_of_max_settlements
num_of_settlements
total_tax_value

Example usage:
Code:
ROOT = {
    export_to_variable = {
        which = count
        who = event_target:my_capital
        value = total_tax_value
    }
    while = {
        limit = {
            check_variable = {
                which = count
                value = 1
            }
        }   
        subtract_variable = {
            which = count
            value = 1
        }
        wealth = 1
    }
}
The current scope will always be holding the variable that is assigned the value but the who parameter is used if you want to export a value from another scope to use in your current scopes variables. If who is not defined it will default to using the current scope when exporting the game value.

In addition to these you can also export modifier values for the different scopes (eg. value = modifier:fertility).
Posted in the feedback thread for export variables. This is now the current functionality for export_to_variable. Please keep the feedback for this specific effect in the linked thread: https://forum.paradoxplaza.com/forum/index.php?threads/script-feature-feedback-request.951329
 
  • 2
Reactions:
I'm just posting here as a notification that I'll be gone on vacation for 3 weeks from now. So be nice towards the team working with Crusader Kings in the meantime and I'll be back soon enough. Hopefully I'll be able to concentrate more on one project at a time then rather than keeping track of all of our projects at the same time. But time will tell what my tasks will be.

Happy modding while I'm brb.
 
  • 3
Reactions: