The script-o-rama is supposed to be a thread about scripting. This thread will serve a few different purposes:
Firstly it's meant as a general scripting discussion point, so if you'd like to just talk about some freak ideas or anything, they're welcome here.
Secondly, I will post stuff like tutorials or little tidbits of information about scripting here, so it'll also turn into a kind of info collection for scripting.
Last and least, if you want to ask me personally some questions, you'd best do it here as I don't particularly like answering them via PM where everything is secret.
This section will contain some short descriptions about functions and objects that are exposed to LuA. Let me start with a list compiled by just that you can get by calling getfenv():
Case sensitivity:
All LuA functions and objects are case-sensitive. That is, CampaignUI is not equal to campaignui, campaignUi or anything like that.
I.1 Object: Effects
The game's general effect library not specifically geared towards scripting.
Click to view content:
adjust_treasury(int amount, context faction)
effect.adjust_treasury will change the treasury of a certain faction.
Spoiler Alert, click show to read:
Parameters: Amount of money, faction context
Example:
Code:
events.FactionTurnStart[#events.FactionTurnStart+1] =
function (context)
effect.adjust_treasury(-1000,context)
end
I.2 Object: Campaign UI
CampaignUI seems to have loads of useful functions (see the list above). Any that I can confirm to work will be listed below.
Click to view content:
CurrentSeasonString()
Calling CampaignUI.CurrentSeasonString() will return the current season as a string.
Spoiler Alert, click show to read:
Returns: Current season as string. One of Summer or Winter
Example:
Code:
CampaignUI.CurrentSeasonString() == "Summer"
Notes:
Be careful about case sensitivity
CurrentTurn()
Calling CampaignUI.CurrentTurn() will return the current turn number.
Spoiler Alert, click show to read:
Returns: Current turn as int.
Example:
Code:
CampaignUI.CurrentTurn() == 0
CurrentYear()
Calling CampaignUI.CurrentYear() will return the current year.
Spoiler Alert, click show to read:
Returns: Current year as int.
Example:
Code:
CampaignUI.CurrentYear() >= 1700
DisplayingTurns()
Calling CampaignUI.DisplayingTurns() will tell you if the game is displaying years or turns.
Spoiler Alert, click show to read:
Returns: Boolean: true if displaying turns, false if displaying years
Example:
Code:
if CampaignUI.DisplayingTurns() then
...
end
EndTurn()
Calling CampaignUI.EndTurn() will end the turn.
Spoiler Alert, click show to read:
Example:
Code:
CampaignUI.EndTurn()
EntityTypeSelected()
CampaignUI.EntityTypeSelected() will give you information about the currently selected game entity
Spoiler Alert, click show to read:
Returns: Entity details table. Important here is CampaignUI.EntityTypeSelected().Entity which holds a pointer (e.g. a Character Pointer) that can be used in other functions
FactionDetails(string faction_key)
CampaignUI.FactionDetails() will give you information about a certain faction.
Spoiler Alert, click show to read:
Arguments: Faction ID string
Returns: Faction details table
Example:
Code:
CampaignUI.FactionDetails("britain")
Will return a table containing this info:
Code:
VictoryConditions: table
Regions: table
1: table
Name: string:New France
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
2: table
Name: string:Georgia
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
3: table
Name: string:Leeward Islands
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
4: table
Name: string:Ireland
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
5: table
Name: string:Gibraltar
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
6: table
Name: string:Florida
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
7: table
Name: string:Hindustan
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
8: table
Name: string:Scotland
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
9: table
Name: string:England
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
ConquestDescription: string:Capture and hold 25 regions by the end of the year 1750, including the regions shown.
TotalRegionsNeeded: number
PrestigeDescription: string:
WealthRanking: string:Spectacular
Leader: table
ActionPointsPerTurn: number
Flag: string:data\ui\flags\britain/portrait_flags.tga
Title: string:
Traits: table
1: table
ExplanationText: string:This man has invested heavily in the navy.
IconFilename: string:data/ui/campaign ui/pips/effect_characters.tga
Name: string:Likes Uniforms
Effects: table
1: table
Priority: number
Description: string:-10% recruitment cost for all naval units
IconFilename: string:data/ui/campaign ui/pips/effect_navy.tga
ColourText: string:He has taken to wearing ceremonial uniforms at all times, which makes bathing a difficult business.
AttributeEffects: table
RemovalText: string:This trait can be lost by more balanced spending.
2: table
ExplanationText: string:Youthful obsessions are one thing, but they are supposed to be set aside.
IconFilename: string:data/ui/campaign ui/pips/effect_characters.tga
Name: string:Lewd and Loose
Effects: table
1: table
Priority: number
Description: string:-10 to diplomatic relations
IconFilename: string:
ColourText: string:This man's behaviour is boorish and nationally embarrassing, even if the ambassador's wife did have a fantastic arse!
AttributeEffects: table
RemovalText: string:This man's ways are set, unfortunately.
Effects: table
1: table
Icon: string:
Tooltip: string:-10 to diplomatic relations
2: table
Icon: string:data/ui/campaign ui/pips/effect_navy.tga
Tooltip: string:-10% recruitment cost for all naval units
PostEffects: table
diplomacy: table
Value: number
Description: string:+0 to diplomatic relations
prestige: table
Value: number
Description: string:+0 Prestige per turn
FactionColour: table
b: number
g: number
r: number
ShowAsCharacter: boolean
IsMilitary: boolean
Attributes: table
morale_sea: table
Value: number
AttributeName: string:Morale
PipPath: string:PLACEHOLDER
research: table
Value: number
AttributeName: string:Research Skill
PipPath: string:data/ui/campaign ui/pips/skill_research.tga
land_siege_engineering: table
Value: number
AttributeName: string:Siege engineering
PipPath: string:PLACEHOLDER
movement_points_land: table
Value: number
AttributeName: string:movement_points_land_name
PipPath: string:PLACEHOLDER
management: table
Value: number
AttributeName: string:Management Skill
PipPath: string:data/ui/campaign ui/pips/skill_managing.tga
PrimaryAttributePath: string:data/ui/campaign ui/pips/skill_managing.tga
PrimaryAttributeName: string:Management Skill
zeal: table
Value: number
AttributeName: string:Religious Zeal
PipPath: string:data/ui/campaign ui/pips/skill_zeal.tga
subterfuge: table
Value: number
AttributeName: string:Subterfuge Skill
PipPath: string:data/ui/campaign ui/pips/skill_spying.tga
duelling_swords: table
Value: number
AttributeName: string:Sword duelling
PipPath: string:data/ui/campaign ui/pips/skill_swordfighting.tga
duelling_pistols: table
Value: number
AttributeName: string:Pistol duelling
PipPath: string:data/ui/campaign ui/pips/skill_shooting.tga
morale_land: table
Value: number
AttributeName: string:Morale
PipPath: string:PLACEHOLDER
trade: table
Value: number
AttributeName: string:Trade
PipPath: string:PLACEHOLDER
PrimaryLevel: number
land_defence_engineering: table
Value: number
AttributeName: string:Land defence engineering
PipPath: string:PLACEHOLDER
command_sea: table
Value: number
AttributeName: string:Command at Sea
PipPath: string:data/ui/campaign ui/pips/skill_naval.tga
command_land: table
Value: number
AttributeName: string:Command on Land
PipPath: string:data/ui/campaign ui/pips/skill_command.tga
Abilities: table
can_research: boolean
can_assassinate: boolean
can_attack_naval: boolean
can_build_religious: boolean
can_attack_land: boolean
can_receive_duel: boolean
can_build_fort: boolean
can_duel: boolean
can_convert: boolean
can_sabotage: boolean
can_spy: boolean
PostName: string:King
CommanderType: number
ActionPoints: number
Post: string:faction_leader
AgentType: string:Minister
IsNaval: boolean
SmallFlag: string:data\ui\flags\britain/small.tga
UniformColour: table
b: number
g: number
r: number
MaskImage: string:
TechImage: string:
Playable: boolean
CardImage: string:data/ui/portraits/european/cards/king/old/014.tga
InfoImage: string:data/ui/portraits/european/Info/king/old/014.jpg
Address: userdata
type: string:Pointer<CHARACTER>
__tostring: function
__eq: function
Location: string:England
Name: string:William III
Age: number
Ancillaries: table
PrestigeRanking: string:Sublime
FlagPath: string:data\ui\flags\britain
UniformColour: table
B: number
G: number
R: number
Address: userdata
type: string:Pointer<FACTION>
__tostring: function
__eq: function
Name: string:Great Britain
PrimaryColour: table
B: number
G: number
R: number
Key: string:britain
PowerRanking: string:Terrifying
InitialiseRegionInfoDetails(<Pointer>REGION)
InitialiseRegionInfoDetails returns all info you can get on a certain region. You have to supply a pointer (get it from RegionsOwnedByFaction for example)
UpperOrder: table
1: table
Total: number: 2
Predicted: number: 0
Positive: boolean: true
PredictedTooltip: string: Government type: 2 (Predicted)||Your government type has a positive effect on this class.
Pip: string: data/ui/campaign ui/pips/government-happy.tga
Tooltip: string: Government type: 2||Your government type has a positive effect on this class.
EqualPipPredictedTooltip: string: Government type: 2 / 2 (Predicted)||Your government type has a positive effect on this class.
2: table
Total: number: 4
Predicted: number: 0
Positive: boolean: false
PredictedTooltip: string: Tax burden: 4 (Predicted)||To lessen the tax burden on your population simply lower taxes.||You can do this on the Government panel.
Pip: string: data/ui/campaign ui/pips/taxes-unhappy.tga
Tooltip: string: Tax burden: 4||To lessen the tax burden on your population simply lower taxes.||You can do this on the Government panel.
EqualPipPredictedTooltip: string: Tax burden: 4 / 4 (Predicted)||To lessen the tax burden on your population simply lower taxes.||You can do this on the Government panel.
3: table
Total: number: 5
Predicted: number: 0
Positive: boolean: false
PredictedTooltip: string: People in government: 5 (Predicted) ||This is from your ministers' traits.||You can view all their traits on the Government panel.
Pip: string: data/ui/campaign ui/pips/character_traits-unhappy.tga
Tooltip: string: People in government: 5 ||This is from your ministers' traits.||You can view all their traits on the Government panel.
EqualPipPredictedTooltip: string: People in government: 5 / 5 (Predicted) ||This is from your ministers' traits.||You can view all their traits on the Government panel.
4: table
Total: number: 1
Predicted: number: 0
Positive: boolean: true
PredictedTooltip: string: Government buildings (Repression): 1 (Predicted)||Increase repression in your regions by upgrading government buildings.
Pip: string: data/ui/campaign ui/pips/buildings-repression.tga
Tooltip: string: Government buildings (Repression): 1||Increase repression in your regions by upgrading government buildings.
EqualPipPredictedTooltip: string: Government buildings (Repression): 1 / 1 (Predicted)||Increase repression in your regions by upgrading government buildings.
5: table
Total: number: 3
Predicted: number: 0
Positive: boolean: true
PredictedTooltip: string: People in government (Repression): 3 (Predicted)||This is from your minister's traits.||You can view all their effects on the Government panel.
Pip: string: data/ui/campaign ui/pips/character_traits-repression.tga
Tooltip: string: People in government (Repression): 3||This is from your minister's traits.||You can view all their effects on the Government panel.
EqualPipPredictedTooltip: string: People in government (Repression): 3 / 3 (Predicted)||This is from your minister's traits.||You can view all their effects on the Government panel.
6: table
Total: number: 1
Predicted: number: 0
Positive: boolean: true
PredictedTooltip: string: Town Watch (Repression): 1 (Predicted)||This is an expensive emergency measure to suppress unrest.
Pip: string: data/ui/campaign ui/pips/policing-repression.tga
Tooltip: string: Town Watch (Repression): 1||This is an expensive emergency measure to suppress unrest.
EqualPipPredictedTooltip: string: Town Watch (Repression): 1 / 1 (Predicted)||This is an expensive emergency measure to suppress unrest.
Total: number: -2
IsPercentage: boolean: false
PipValue: number: 1
ReligionKey: string: rel_catholic
WealthChange: number: 2
Settlement: string: Cayenne
Wealth: number: 782
ActiveLowerClass: string: Lower Class
TownWealth: table
1: table
Total: number: 3
Predicted: number: 0
Positive: boolean: true
PredictedTooltip: string: Ports: 3 (Predicted) ||Increase this by developing your trading ports and fisheries.
Pip: string: data/ui/campaign ui/pips/eco-trade_harbour.tga
Tooltip: string: Ports: 3 ||Increase this by developing your trading ports and fisheries.
EqualPipPredictedTooltip: string: Ports: 3 / 3 (Predicted) ||Increase this by developing your trading ports and fisheries.
2: table
Total: number: 8
Predicted: number: 1
Positive: boolean: false
PredictedTooltip: string: Tax: 9 (Predicted) ||Tax rates are slowing economic growth.||Reduce this by lowering tax rates.
Pip: string: data/ui/campaign ui/pips/taxes-unhappy.tga
Tooltip: string: Tax: 8 ||Tax rates are slowing economic growth.||Reduce this by lowering tax rates.
EqualPipPredictedTooltip: string: Tax: 8 / 9 (Predicted) ||Tax rates are slowing economic growth.||Reduce this by lowering tax rates.
3: table
Total: number: 3
Predicted: number: 2
Positive: boolean: true
PredictedTooltip: string: Enlightenment: 5 (Predicted) ||Researching certain technologies increases economic growth.
Pip: string: data/ui/campaign ui/pips/town_research.tga
Tooltip: string: Enlightenment: 3 ||Researching certain technologies increases economic growth.
EqualPipPredictedTooltip: string: Enlightenment: 3 / 5 (Predicted) ||Researching certain technologies increases economic growth.
PipValue: number: 50
Total: number: -2
IsPercentage: boolean: false
Taxed: boolean: true
ReligiousBreakdown: table
1: table
Change: number: 0
Name: string: Animism
Key: string: rel_animist
Icon: string: data/ui/campaign ui/pips/animism.tga
Percentage: number: 15.000000953674
2: table
Change: number: 0
Name: string: Catholicism
Key: string: rel_catholic
Icon: string: data/ui/campaign ui/pips/roman_catholic.tga
Percentage: number: 85.000007629395
RegionWealth: table
1: table
Total: number: 440
LostTooltip: string: Port: 0 (Predicted)
Positive: boolean: true
Tooltip: string: Port: 440
EqualPipPredictedTooltip: string: Port: 440
Predicted: number: 0
Lost: number: 0
PredictedTooltip: string: Port: 440 (Predicted)
Pip: string: data/ui/campaign ui/pips/trade_port.tga
2: table
Total: number: 342
LostTooltip: string: Spice exports: 0 (0 Pounds) (Predicted)
Positive: boolean: true
Tooltip: string: Spice exports: 342 (18 Pounds)
EqualPipPredictedTooltip: string: Spice exports: 342 (18 Pounds)
Predicted: number: 0
Lost: number: 0
PredictedTooltip: string: Spice exports: 342 (18 Pounds) (Predicted)
Pip: string: data/ui/campaign ui/pips/spices.tga
PipValue: number: 50
Total: number: 782
IsPercentage: boolean: false
PopulationGrowth: table
1: table
Total: number: 0.29999998211861
Predicted: number: 0
Positive: boolean: true
PredictedTooltip: string: Subsistence agriculture: 0.3% (Predicted)||This is the background level of food production in the region.
Pip: string: data/ui/campaign ui/pips/population_subsistence.tga
Tooltip: string: Subsistence agriculture: 0.3%||This is the background level of food production in the region.
EqualPipPredictedTooltip: string: Subsistence agriculture: 0.3% / 0.3% (Predicted)||This is the background level of food production in the region.
2: table
Total: number: 0.37000000476837
Predicted: number: 0
Positive: boolean: false
PredictedTooltip: string: Tax burden: 0.37% (Predicted)||To counter this, simply lower taxes for the lower classes.||You can do this on the Government panel.
Pip: string: data/ui/campaign ui/pips/taxes-unhappy.tga
Tooltip: string: Tax burden: 0.37%||To counter this, simply lower taxes for the lower classes.||You can do this on the Government panel.
EqualPipPredictedTooltip: string: Tax burden: 0.37% / 0.37% (Predicted)||To counter this, simply lower taxes for the lower classes.||You can do this on the Government panel.
3: table
Total: number: 5.0099997520447
Predicted: number: 0
Positive: boolean: true
PredictedTooltip: string: Immigration from the home theatre: 5.01% (Predicted)||Unhappiness drives people to seek a better life elsewhere.
Pip: string: data/ui/campaign ui/pips/migration_happy.tga
Tooltip: string: Immigration from the home theatre: 5.01%||Unhappiness drives people to seek a better life elsewhere.
EqualPipPredictedTooltip: string: Immigration from the home theatre: 5.01% / 5.01% (Predicted)||Unhappiness drives people to seek a better life elsewhere.
PipValue: number: 0.0099999997764826
Total: number: 4.9399995803833
IsPercentage: boolean: true
UpperTax: number: 0.16489998996258
Theatre: string: 1
Effects: table
Governor: table
ActionPointsPerTurn: number: 0
Flag: string: data\ui\flags\france/portrait_flags.tga
Title: string:
Traits: table
1: table
ExplanationText: string: This fellow believes that ministers should set the right example.
IconFilename: string: data/ui/campaign ui/pips/effect_characters.tga
Name: string: Honest
Effects: table
ColourText: string: This man believes in truth and honesty, something he pursues through his work.
AttributeEffects: table
1: string: +1 to Management.
RemovalText: string: This trait is permanent and cannot be lost.
2: table
ExplanationText: string: This man has done much for his nation's cultural landscape.
IconFilename: string: data/ui/campaign ui/pips/effect_characters.tga
Name: string: Sybarite
Effects: table
1: table
Priority: number: 9019
Description: string: +1 happiness (lower classes)
IconFilename: string: data/ui/campaign ui/pips/effect_public_order.tga
2: table
Priority: number: 9017
Description: string: -1 happiness (nobility)
IconFilename: string: data/ui/campaign ui/pips/effect_public_order.tga
ColourText: string: Whereas most people can be appeased with cheap whores and gin by the bucket, some of us have more refined tastes.
AttributeEffects: table
RemovalText: string: This character trait cannot be lost, only improved.
3: table
ExplanationText: string: The treasury has remained virtually untouched since he took charge.
IconFilename: string: data/ui/campaign ui/pips/effect_characters.tga
Name: string: Frugal and Thrifty
Effects: table
1: table
Priority: number: 4
Description: string: -2 to Management for treasury administration
IconFilename: string: data/ui/campaign ui/pips/effect_economy.tga
2: table
Priority: number: 9017
Description: string: -1 happiness (nobility)
IconFilename: string: data/ui/campaign ui/pips/effect_public_order.tga
ColourText: string: He keeps a tight rein on the privy purse strings, all expenditure must be justified in writing. In triplicate.
AttributeEffects: table
1: string: +1 to Management.
RemovalText: string: This character trait can be lost by more generous use of tax income.
PostEffects: table
tax_efficiency: table
Value: number: 4
Description: string: +4% bonus to tax income across theatre
repression: table
Value: number: 2
Description: string: +2 to repression across the theatre
land_upkeep_cost: table
Value: number: -4
Description: string: -4% upkeep costs for all army units
FactionColour: table
b: number: 240
g: number: 255
r: number: 255
ShowAsCharacter: boolean: true
Effects: table
1: table
Icon: string: data/ui/campaign ui/pips/effect_public_order.tga
Tooltip: string: +1 happiness (lower classes)
2: table
Icon: string: data/ui/campaign ui/pips/effect_public_order.tga
Tooltip: string: -2 happiness (nobility)
3: table
Icon: string: data/ui/campaign ui/pips/effect_economy.tga
Tooltip: string: -2 to Management for treasury administration
IsMilitary: boolean: false
Attributes: table
morale_sea: table
Value: number: -1
AttributeName: string: Morale
PipPath: string: PLACEHOLDER
research: table
Value: number: -1
AttributeName: string: Research Skill
PipPath: string: data/ui/campaign ui/pips/skill_research.tga
land_siege_engineering: table
Value: number: -1
AttributeName: string: Siege engineering
PipPath: string: PLACEHOLDER
movement_points_land: table
Value: number: -1
AttributeName: string: movement_points_land_name
PipPath: string: PLACEHOLDER
management: table
Value: number: 4
AttributeName: string: Management Skill
PipPath: string: data/ui/campaign ui/pips/skill_managing.tga
PrimaryAttributePath: string: data/ui/campaign ui/pips/skill_managing.tga
PrimaryAttributeName: string: Management Skill
zeal: table
Value: number: -1
AttributeName: string: Religious Zeal
PipPath: string: data/ui/campaign ui/pips/skill_zeal.tga
subterfuge: table
Value: number: -1
AttributeName: string: Subterfuge Skill
PipPath: string: data/ui/campaign ui/pips/skill_spying.tga
duelling_swords: table
Value: number: -1
AttributeName: string: Sword duelling
PipPath: string: data/ui/campaign ui/pips/skill_swordfighting.tga
duelling_pistols: table
Value: number: -1
AttributeName: string: Pistol duelling
PipPath: string: data/ui/campaign ui/pips/skill_shooting.tga
morale_land: table
Value: number: -1
AttributeName: string: Morale
PipPath: string: PLACEHOLDER
trade: table
Value: number: -1
AttributeName: string: Trade
PipPath: string: PLACEHOLDER
PrimaryLevel: number: 5
land_defence_engineering: table
Value: number: -1
AttributeName: string: Land defence engineering
PipPath: string: PLACEHOLDER
command_sea: table
Value: number: -1
AttributeName: string: Command at Sea
PipPath: string: data/ui/campaign ui/pips/skill_naval.tga
command_land: table
Value: number: -1
AttributeName: string: Command on Land
PipPath: string: data/ui/campaign ui/pips/skill_command.tga
Abilities: table
can_research: boolean: false
can_assassinate: boolean: false
can_attack_naval: boolean: false
can_build_religious: boolean: false
can_attack_land: boolean: false
can_receive_duel: boolean: false
can_build_fort: boolean: false
can_duel: boolean: false
can_convert: boolean: false
can_sabotage: boolean: false
can_spy: boolean: false
CommanderType: number: 0
ActionPoints: number: 0
Post: string: governor_america
AgentType: string: Minister
IsNaval: boolean: false
SmallFlag: string: data\ui\flags\france/small.tga
UniformColour: table
b: number: 240
g: number: 255
r: number: 255
MaskImage: string:
TechImage: string:
Playable: boolean: false
CardImage: string: data/ui/portraits/european/Cards/minister/young/077.tga
InfoImage: string: data/ui/portraits/european/Info/minister/young/077.jpg
Address: userdata
type: string: Pointer<CHARACTER>
__tostring: function
__eq: function
Location: string: France
Name: string: Gaston Rousseau
Age: number: 43
Ancillaries: table
OwningFactionKey: string: france
AdministrationCostPercentage: number: -0.029999999329448
GovernorPercentage: number: 0.03999999910593
LowerTax: number: 0.16489998996258
BuildingPercentage: number: 0
UpperTaxPercentage: number: 0.1499999910593
PopulationNumber: number: 4390
Population: string: 4390
LowerTaxPercentage: number: 0.1499999910593
Name: string: French Guyana
Address: userdata
type: string: Pointer<REGION>
__tostring: function
__eq: function
LowerOrder: table
1: table
Total: number: 4
Predicted: number: 0
Positive: boolean: false
PredictedTooltip: string: Tax burden: 4 (Predicted)||To lessen the tax burden on your population simply lower taxes.||You can do this on the Government panel.
Pip: string: data/ui/campaign ui/pips/taxes-unhappy.tga
Tooltip: string: Tax burden: 4||To lessen the tax burden on your population simply lower taxes.||You can do this on the Government panel.
EqualPipPredictedTooltip: string: Tax burden: 4 / 4 (Predicted)||To lessen the tax burden on your population simply lower taxes.||You can do this on the Government panel.
2: table
Total: number: 2
Predicted: number: 0
Positive: boolean: false
PredictedTooltip: string: People in government: 2 (Predicted) ||This is from your ministers' traits.||You can view all their traits on the Government panel.
Pip: string: data/ui/campaign ui/pips/character_traits-unhappy.tga
Tooltip: string: People in government: 2 ||This is from your ministers' traits.||You can view all their traits on the Government panel.
EqualPipPredictedTooltip: string: People in government: 2 / 2 (Predicted) ||This is from your ministers' traits.||You can view all their traits on the Government panel.
3: table
Total: number: 1
Predicted: number: 0
Positive: boolean: true
PredictedTooltip: string: Government buildings (Repression): 1 (Predicted)||Increase repression in your regions by upgrading government buildings.
Pip: string: data/ui/campaign ui/pips/buildings-repression.tga
Tooltip: string: Government buildings (Repression): 1||Increase repression in your regions by upgrading government buildings.
EqualPipPredictedTooltip: string: Government buildings (Repression): 1 / 1 (Predicted)||Increase repression in your regions by upgrading government buildings.
4: table
Total: number: 3
Predicted: number: 0
Positive: boolean: true
PredictedTooltip: string: People in government (Repression): 3 (Predicted)||This is from your minister's traits.||You can view all their effects on the Government panel.
Pip: string: data/ui/campaign ui/pips/character_traits-repression.tga
Tooltip: string: People in government (Repression): 3||This is from your minister's traits.||You can view all their effects on the Government panel.
EqualPipPredictedTooltip: string: People in government (Repression): 3 / 3 (Predicted)||This is from your minister's traits.||You can view all their effects on the Government panel.
5: table
Total: number: 1
Predicted: number: 0
Positive: boolean: true
PredictedTooltip: string: Town Watch (Repression): 1 (Predicted)||This is an expensive emergency measure to suppress unrest.
Pip: string: data/ui/campaign ui/pips/policing-repression.tga
Tooltip: string: Town Watch (Repression): 1||This is an expensive emergency measure to suppress unrest.
EqualPipPredictedTooltip: string: Town Watch (Repression): 1 / 1 (Predicted)||This is an expensive emergency measure to suppress unrest.
IsPercentage: boolean: false
PipValue: number: 1
Total: number: -1
ActiveUpperClass: string: Nobility
ReligionIcon: string: data/ui/campaign ui/pips/roman_catholic.tga
PopulationChange: number: 1
IsCharacterPlayerControlled(CharacterPointer pointer)
CampaignUI.IsCharacterPlayerControlled() will tell you whether a character is controlled by the player.
Spoiler Alert, click show to read:
Returns: boolean true or false
Example:
Code:
entity = CampaignUI.EntityTypeSelected()
if entity.Character then
if CampaignUI.IsCharacterPlayerControlled(entity.Entity) then
...
end
end
PlayerFactionId()
Calling CampaignUI.PlayerFactionId() will return the player's faction key.
Spoiler Alert, click show to read:
Returns: Faction ID as a string, e.g. "britain"
Example:
Code:
CampaignUI.PlayerFactionId() == "britain"
PrestigeDetails()
CampaignUI.PrestigeDetails() will give you access to the prestige points for each faction
RegionsOwnedByFaction(<faction_key>)
CampaignUI.RegionsOwnedByFaction() will give you a list of all of a faction's regions
Spoiler Alert, click show to read:
Parameters: Faction key as string
Returns: Table with a list of region pointers and localised region names
Example:
Code:
CampaignUI.RegionsOwnedByFaction("britain")
Will return a table containing this info:
Code:
1: table
Name: string: Ireland
Address: userdata
type: string: Pointer<REGION>
__tostring: function
__eq: function
2: table
Name: string: England
Address: userdata
type: string: Pointer<REGION>
__tostring: function
__eq: function
3: table
Name: string: Jamaica
Address: userdata
type: string: Pointer<REGION>
__tostring: function
__eq: function
4: table
Name: string: Bahamas
Address: userdata
type: string: Pointer<REGION>
__tostring: function
__eq: function
5: table
Name: string: Rupert's Land
Address: userdata
type: string: Pointer<REGION>
__tostring: function
__eq: function
6: table
Name: string: Scotland
Address: userdata
type: string: Pointer<REGION>
__tostring: function
__eq: function
RetrieveFactionRegionList(<faction_key>)
CampaignUI.RetrieveFactionRegionList() will give you a list of all of a faction's settlements. Similar to RegionsOwnedByFaction but returns settlement pointers instead of region pointers
Spoiler Alert, click show to read:
Parameters: Faction key as string
Returns: Table with a list of settlement pointers
Example:
Code:
CampaignUI.RetrieveFactionRegionList("britain")
Will return a table containing this info:
Code:
1: table
SettlementAddress: userdata
type: string: Pointer<SETTLEMENT>
__tostring: function
__eq: function
2: table
SettlementAddress: userdata
type: string: Pointer<SETTLEMENT>
__tostring: function
__eq: function
3: table
SettlementAddress: userdata
type: string: Pointer<SETTLEMENT>
__tostring: function
__eq: function
4: table
SettlementAddress: userdata
type: string: Pointer<SETTLEMENT>
__tostring: function
__eq: function
5: table
SettlementAddress: userdata
type: string: Pointer<SETTLEMENT>
__tostring: function
__eq: function
6: table
SettlementAddress: userdata
type: string: Pointer<SETTLEMENT>
__tostring: function
__eq: function
RetrieveFactionMilitaryForceLists(<faction_key>,armies/navies)
CampaignUI.RetrieveFactionMilitaryForceLists() will give you a list of all of a faction's armies or navies.
Spoiler Alert, click show to read:
Parameters: Faction key as string, armies or navies as bool (armies = true)
Returns: Table with a huge list of army or navy details
1: table
ActionPointsPerTurn: number: 22
Transitioning: boolean: false
Ancillaries: table
Traits: table
Flag: string: data\ui\flags\france/portrait_flags.tga
Effects: table
Abilities: table
can_research: boolean: false
can_assassinate: boolean: false
can_attack_naval: boolean: false
can_build_religious: boolean: false
can_attack_land: boolean: true
can_receive_duel: boolean: false
can_build_fort: boolean: false
can_duel: boolean: false
can_convert: boolean: false
can_sabotage: boolean: false
can_spy: boolean: false
Attributes: table
morale_sea: table
Value: number: -1
AttributeName: string: Morale
PipPath: string: PLACEHOLDER
research: table
Value: number: -1
AttributeName: string: Research Skill
PipPath: string: data/ui/campaign ui/pips/skill_research.tga
land_siege_engineering: table
Value: number: -1
AttributeName: string: Siege engineering
PipPath: string: PLACEHOLDER
movement_points_land: table
Value: number: -1
AttributeName: string: movement_points_land_name
PipPath: string: PLACEHOLDER
management: table
Value: number: -1
AttributeName: string: Management Skill
PipPath: string: data/ui/campaign ui/pips/skill_managing.tga
PrimaryAttributePath: string: data/ui/campaign ui/pips/skill_command.tga
PrimaryAttributeName: string: Command on Land
zeal: table
Value: number: -1
AttributeName: string: Religious Zeal
PipPath: string: data/ui/campaign ui/pips/skill_zeal.tga
subterfuge: table
Value: number: -1
AttributeName: string: Subterfuge Skill
PipPath: string: data/ui/campaign ui/pips/skill_spying.tga
duelling_swords: table
Value: number: -1
AttributeName: string: Sword duelling
PipPath: string: data/ui/campaign ui/pips/skill_swordfighting.tga
duelling_pistols: table
Value: number: -1
AttributeName: string: Pistol duelling
PipPath: string: data/ui/campaign ui/pips/skill_shooting.tga
morale_land: table
Value: number: -1
AttributeName: string: Morale
PipPath: string: PLACEHOLDER
trade: table
Value: number: -1
AttributeName: string: Trade
PipPath: string: PLACEHOLDER
PrimaryLevel: number: 1
land_defence_engineering: table
Value: number: -1
AttributeName: string: Land defence engineering
PipPath: string: PLACEHOLDER
command_sea: table
Value: number: -1
AttributeName: string: Command at Sea
PipPath: string: data/ui/campaign ui/pips/skill_naval.tga
command_land: table
Value: number: 0
AttributeName: string: Command on Land
PipPath: string: data/ui/campaign ui/pips/skill_command.tga
IsMilitary: boolean: true
FactionColour: table
b: number: 240
g: number: 255
r: number: 255
ShowAsCharacter: boolean: false
PosX: number: 16.522933959961
Soldiers: number: 122
Units: number: 3
PosY: number: 347.06695556641
CommanderType: number: 5
ActionPoints: number: 22
Title: string:
AgentType: string: Brigadier
IsNaval: boolean: false
SmallFlag: string: data\ui\flags\france/small.tga
UniformColour: table
b: number: 240
g: number: 255
r: number: 255
MaskImage: string: data/ui/units/icons/Euro_Provincial_Cavalry_icon_cavs_mask.tga
TechImage: string:
Playable: boolean: true
CardImage: string: data/ui/units/icons/Euro_Provincial_Cavalry_icon_cavs.tga
InfoImage: string:
Address: userdata
type: string: Pointer<CHARACTER>
__tostring: function
__eq: function
Location: string: Paris
Name: string: Charles Lagrange
Age: number: 18
CommandedUnit: table
Charge: number: 7
DisplayAsUnit: boolean: true
Reloading: number: 0
FactionColour: table
b: number: 240
g: number: 255
r: number: 255
Firepower: number: 0
Manoeuvrability: string: manoeuverability_medium
InTransit: boolean: false
RecruitCost: number: 975
CommanderType: number: 5
Accuracy: number: 0
Id: string: unit35
Defence: number: 5
knowledge_mask: number: 15
PromotionCost: number: 1950
IsArtillery: boolean: false
Replenished: boolean: false
Men: number: 30
Ammunition: number: 0
Description: string: These locally recruited cavalry are a valuable aid in keeping order.
InfoPic: string: data/ui/units/info/euro_provincial_cavalry
Replenishable: boolean: false
UnitRecord: table
Ammunition: number: 0
RecruitTime: number: 1
UpkeepCost: number: 310
InfoPic: string: data/ui/units/info/euro_provincial_cavalry
Class: string: Cavalry
Range: number: 0
MPCost: number: 650
Key: string: euro_provincial_cavalry_gendarmerie
IsArtillery: boolean: false
IsNaval: boolean: false
Experience: number: 0
RecruitCost: number: 975
Men: number: 60
Defence: number: 5
Reloading: number: 0
Melee: number: 10
Accuracy: number: 0
Firepower: number: 0
DisplayNumber: number: 60
ClassID: number: 9
Charge: number: 7
Guns: number: 0
Description: string: These locally recruited cavalry are a valuable aid in keeping order.
Name: string: Gendarmerie
Morale: number: 7
SiegeUnit: boolean: false
Icon: string: data/ui/units/icons/Euro_Provincial_Cavalry_icon_cavs
LongDescription: string:
These light horsemen are often little more than mounted militia, but with a greater social standing. Cavalry always see themselves as better than footsoldiers, but in this case, it may be true. It is, after all, not cheap to purchase and maintain a decent horse, and this means that men with financial standing make up the majority of recruits.
They are, however, not as disciplined as regular cavalry, simply because they do not have the time or available resources to learn the craft of war as thoroughly. They are, however, extremely useful in policing the rougher, lower orders and keeping the existing social structure intact.
Historically, there are many examples of yeomanry or gendarmes turning on their own citizenry with surprising and horrific violence. They were widely used against the anti-factory Luddites in northern England and, most infamously, were responsible for the Peterloo Massacre in 1819, when the Manchester and Salford Yeomanry charged a mostly peaceful, but excited crowd, and cut down many unarmed protestors.
MPCategory: number: 1
RegimentName: string: 1st Regiment of Horse
LongDescription: string:
These light horsemen are often little more than mounted militia, but with a greater social standing. Cavalry always see themselves as better than footsoldiers, but in this case, it may be true. It is, after all, not cheap to purchase and maintain a decent horse, and this means that men with financial standing make up the majority of recruits.
They are, however, not as disciplined as regular cavalry, simply because they do not have the time or available resources to learn the craft of war as thoroughly. They are, however, extremely useful in policing the rougher, lower orders and keeping the existing social structure intact.
Historically, there are many examples of yeomanry or gendarmes turning on their own citizenry with surprising and horrific violence. They were widely used against the anti-factory Luddites in northern England and, most infamously, were responsible for the Peterloo Massacre in 1819, when the Manchester and Salford Yeomanry charged a mostly peaceful, but excited crowd, and cut down many unarmed protestors.
ExistingUnit: boolean: true
Speed: number: 0
UniformColour: table
b: number: 240
g: number: 255
r: number: 255
Icon: string: data/ui/units/icons/Euro_Provincial_Cavalry_icon_cavs
NeedsRepair: boolean: false
ActionPoints: number: 28
RepairCost: number: 0
Melee: number: 10
IsNaval: boolean: false
ShowAsCharacter: boolean: false
UpkeepCost: number: 298
Portrait: string:
Range: number: 0
HullStrength: number: 0
Morale: number: 7
Experience: number: 0
Address: userdata
type: string: Pointer<UNIT>
__tostring: function
__eq: function
Traits: table
Guns: number: 0
Name: string: Gendarmerie
CommandersName: string: Charles Lagrange
2: table
ActionPointsPerTurn: number: 23
Transitioning: boolean: false
...
I.2 Object: Game Interface
Called by using scripting.game_interface (after requiring the EpisodicScripting package) this is the primary package to allow us to change things in the game. Unfortunately it doesn't have too much content yet.
Click to view content:
add_restricted_unit_record(<unit_key>)
add_restricted_unit_record allows you to remove a unit from being available for recruitment world-wide (similar to the SF units)
Spoiler Alert, click show to read:
Parameters: Unit key as string (as it appears in the units table)
remove_restricted_unit_record(<unit_key>)
remove_restricted_unit_record removes the restriction on a unit record that was previously set with add_restricted_unit_record
Spoiler Alert, click show to read:
Parameters: Unit key as string (as it appears in the units table)
Saving the game
Note: this is for my own reference, if you don't understand it don't bother
For saving, three types should be distinguished:
- Save via the save-load dialog
- Autosave
- Quicksave via shortcut
If you need a savegame list, the savegame will be missing during save - that's a way to know the filename of the game that was just saved. Unfortunately we then need an event that we can use after saving and that can be enabled by a bool flag.
For the saving via save-load, use PanelOpenedCampaign, if you want with context.string == dialogue_box (this is called by the "Save successful" dialog).
For saving via auto-save, use FactionTurnEnd or somesuch
For saving via quicksave we can get a problem if the player hits alt+f4 so we need to use FactionTurnEnd along with the auto-save and UIDestroyed
Last edited by alpaca; April 20, 2009 at 12:20 PM.
nice Alpaca always good to see you work
is their a disabled royal family button?
Minister for Home Affairs of the Commonwealth v Zentai [2012] HCA 28 per Heydon J at [75]
Analysis should not be diverted by reflections upon the zeal with which the victors at the end of the Second World War punished the defeated for war crimes. The victors were animated by the ideals of the Atlantic Charter and of the United Nations. The Universal Declaration of Human Rights was about to peep over the eastern horizon. But first, they wanted a little hanging.
nice Alpaca always good to see you work
is their a disabled royal family button?
Haven't really dug in yet. There's a lot of stuff that'll be hard to get at and this isn't actually UI editing. I'll make a mental note of keeping the royal family in mind though.
Currently busy testing all this stuff I can get at thanks to just
By the way, it seems like since I scalded CA for not exposing objects to LuA I should now apologise. There's much more here than I thought
At first i wanna say: many thanks im waiting for something like this
Do you have a list of usefull events you could post also?
I allredy have the list about battle events, but im searching for more campain related events like:
At first i wanna say: many thanks im waiting for something like this
Do you have a list of usefull events you could post also?
I allredy have the list about battle events, but im searching for more campain related events like:
Extract events.lua from the patch.pack, it has all registered events.
Extract events.lua from the patch.pack, it has all registered events.
I know thats where i got the samples from, i was just hoping someone allredy has a list of em, with description just like your UICampain object overview.
No, compiling a list is a lot of work and the events are mostly self-explanatory. If I get around to it I'll add some important ones here. If you like to, you could start working on it and I'll put it in the first post.
Alpaca, don't these function require a context as argument, or is that just something weird that the game scripts have?
For the royal family stuff, there is a monarchy script which has a card, it should be able to show this with UICardManager.AddCard but I don't yet know what arguments etc. are needed.
Alpaca, don't these function require a context as argument, or is that just something weird that the game scripts have?
Well FactionDetails doesn't use a context. I tested it and it crashed. I'm not yet sure if you can get that from the pointer or so, we'll have to see.
Edit: Ok, this is the FactionDetails output:
Spoiler Alert, click show to read:
Code:
VictoryConditions: table
Regions: table
1: table
Name: string:New France
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
2: table
Name: string:Georgia
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
3: table
Name: string:Leeward Islands
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
4: table
Name: string:Ireland
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
5: table
Name: string:Gibraltar
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
6: table
Name: string:Florida
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
7: table
Name: string:Hindustan
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
8: table
Name: string:Scotland
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
9: table
Name: string:England
Address: userdata
type: string:Pointer<REGION>
__tostring: function
__eq: function
ConquestDescription: string:Capture and hold 25 regions by the end of the year 1750, including the regions shown.
TotalRegionsNeeded: number
PrestigeDescription: string:
WealthRanking: string:Spectacular
Leader: table
ActionPointsPerTurn: number
Flag: string:data\ui\flags\britain/portrait_flags.tga
Title: string:
Traits: table
1: table
ExplanationText: string:This man has invested heavily in the navy.
IconFilename: string:data/ui/campaign ui/pips/effect_characters.tga
Name: string:Likes Uniforms
Effects: table
1: table
Priority: number
Description: string:-10% recruitment cost for all naval units
IconFilename: string:data/ui/campaign ui/pips/effect_navy.tga
ColourText: string:He has taken to wearing ceremonial uniforms at all times, which makes bathing a difficult business.
AttributeEffects: table
RemovalText: string:This trait can be lost by more balanced spending.
2: table
ExplanationText: string:Youthful obsessions are one thing, but they are supposed to be set aside.
IconFilename: string:data/ui/campaign ui/pips/effect_characters.tga
Name: string:Lewd and Loose
Effects: table
1: table
Priority: number
Description: string:-10 to diplomatic relations
IconFilename: string:
ColourText: string:This man's behaviour is boorish and nationally embarrassing, even if the ambassador's wife did have a fantastic arse!
AttributeEffects: table
RemovalText: string:This man's ways are set, unfortunately.
Effects: table
1: table
Icon: string:
Tooltip: string:-10 to diplomatic relations
2: table
Icon: string:data/ui/campaign ui/pips/effect_navy.tga
Tooltip: string:-10% recruitment cost for all naval units
PostEffects: table
diplomacy: table
Value: number
Description: string:+0 to diplomatic relations
prestige: table
Value: number
Description: string:+0 Prestige per turn
FactionColour: table
b: number
g: number
r: number
ShowAsCharacter: boolean
IsMilitary: boolean
Attributes: table
morale_sea: table
Value: number
AttributeName: string:Morale
PipPath: string:PLACEHOLDER
research: table
Value: number
AttributeName: string:Research Skill
PipPath: string:data/ui/campaign ui/pips/skill_research.tga
land_siege_engineering: table
Value: number
AttributeName: string:Siege engineering
PipPath: string:PLACEHOLDER
movement_points_land: table
Value: number
AttributeName: string:movement_points_land_name
PipPath: string:PLACEHOLDER
management: table
Value: number
AttributeName: string:Management Skill
PipPath: string:data/ui/campaign ui/pips/skill_managing.tga
PrimaryAttributePath: string:data/ui/campaign ui/pips/skill_managing.tga
PrimaryAttributeName: string:Management Skill
zeal: table
Value: number
AttributeName: string:Religious Zeal
PipPath: string:data/ui/campaign ui/pips/skill_zeal.tga
subterfuge: table
Value: number
AttributeName: string:Subterfuge Skill
PipPath: string:data/ui/campaign ui/pips/skill_spying.tga
duelling_swords: table
Value: number
AttributeName: string:Sword duelling
PipPath: string:data/ui/campaign ui/pips/skill_swordfighting.tga
duelling_pistols: table
Value: number
AttributeName: string:Pistol duelling
PipPath: string:data/ui/campaign ui/pips/skill_shooting.tga
morale_land: table
Value: number
AttributeName: string:Morale
PipPath: string:PLACEHOLDER
trade: table
Value: number
AttributeName: string:Trade
PipPath: string:PLACEHOLDER
PrimaryLevel: number
land_defence_engineering: table
Value: number
AttributeName: string:Land defence engineering
PipPath: string:PLACEHOLDER
command_sea: table
Value: number
AttributeName: string:Command at Sea
PipPath: string:data/ui/campaign ui/pips/skill_naval.tga
command_land: table
Value: number
AttributeName: string:Command on Land
PipPath: string:data/ui/campaign ui/pips/skill_command.tga
Abilities: table
can_research: boolean
can_assassinate: boolean
can_attack_naval: boolean
can_build_religious: boolean
can_attack_land: boolean
can_receive_duel: boolean
can_build_fort: boolean
can_duel: boolean
can_convert: boolean
can_sabotage: boolean
can_spy: boolean
PostName: string:King
CommanderType: number
ActionPoints: number
Post: string:faction_leader
AgentType: string:Minister
IsNaval: boolean
SmallFlag: string:data\ui\flags\britain/small.tga
UniformColour: table
b: number
g: number
r: number
MaskImage: string:
TechImage: string:
Playable: boolean
CardImage: string:data/ui/portraits/european/cards/king/old/014.tga
InfoImage: string:data/ui/portraits/european/Info/king/old/014.jpg
Address: userdata
type: string:Pointer<CHARACTER>
__tostring: function
__eq: function
Location: string:England
Name: string:William III
Age: number
Ancillaries: table
PrestigeRanking: string:Sublime
FlagPath: string:data\ui\flags\britain
UniformColour: table
B: number
G: number
R: number
Address: userdata
type: string:Pointer<FACTION>
__tostring: function
__eq: function
Name: string:Great Britain
PrimaryColour: table
B: number
G: number
R: number
Key: string:britain
PowerRanking: string:Terrifying
Last edited by alpaca; March 28, 2009 at 08:34 AM.
This post was made before, I was awake, and at the time I thought this was hilarious, if a passing mod could delete this it would be nice.
Last edited by Titan Uranus; March 28, 2009 at 11:56 AM.
Love your enemy, it'll scare the hell out of him.-Mark Twain
"'Khe San' died. Peacefully, in bed. Of gunshot wounds."
-Darius Jedburgh, Edge Of Darkness
Tangential question:
I found some functions for special abilities such as:
BattleUI.Current_Selection_Enable_Light_Infantry_Behaviour
BattleUI.Current_Selection_Enable_Prone_Formation
in UI.pack\ui\battle ui\land_battle_orders_scripts\land_hud_special_ability_button.luac.
Where can I find definitions for these and are they modifiable?
They're probably defined in that file. You can't edit .luac files because they're compiled though (unless you find a decompiler that works with these files).
Sorry for the lack of updating, there simply aren't enough hours in the day. I found out something new:
CA implemented traits for regions! There are some in vanilla that you can use for testing purposes, like R_Infected_Cholera. To test it, you can use this (put it into triggers or the campaign script, somebody needs to write a traits tutorial):
Code:
events.RegionTurnStart[#events.RegionTurnStart+1] =
function (context)
effect.trait("R_Infected_Cholera","region",1,100,context)
end
Now why is this great? Easy: Add a trait effect to the region trait, for example happy_industrialisation_lower, and you can now change region stats like you would with buildings. So... we can for example create scripted traits that change what happens when the player conquers a region - for example the resistance effect could be vastly increased, taxes could be lowered, recruitment disabled, anything goes! I'm very excited about this feature
They even show up in the UI as a small pip, not sure yet how to change their appearance or give them a tooltip but I hope that's possible.
Ok i put it in a script file but it doesn't work for me.. Do i need conditions? If so what condition can you use to get it to work..
Did you see gain message? It should work but the trait doesn't have an effect right now.
Unfortunately, CA threw more sticks between our legs than I'd have thought though, scripting in this game is like being in a glass maze when they should have built a tunnel: you know the exit is right behind the wall but you can only get there by a very roundabout path.