Results 1 to 16 of 16

Thread: Script-o-Rama 2 (UPDATED 16/06/13)

  1. #1

    Default Script-o-Rama 2 (UPDATED 16/06/13)

    The NTW Script-o-Rama is a resource based on alpaca's ETW Script-o-Rama that aims to serve many similar 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 it will serve as a focal point for scripting help and advice. You will find a lot of information here that alpaca never got round to posting in his old thread. Most of the info here will work in ETW and NTW
    This thread will also be updated periodically

    NOTE: Some of the content here is completely alpaca's work, I have just updated it and added a lot of new info. Credit goes to him for the idea and the basis of this work


    Table of Contents:

    I. Basic Introduction & Scripting DocumentationII. Script Writing TutorialsIII. Miscellaneous




    Section I: Basic Introduction & Scripting Documentation


    This section will explain some basic scripting rules, and give some tips to help get you started. Also contained here is extensive script documentation on usage, output, arguments and caveats.


    I.1 Basics:

    Click to view content: 

    Scripting Language:
    NTW uses Lua. So what is Lua?
    Lua is a powerful, fast, lightweight, embeddable scripting language.
    Lua is an open source, very fast, real-world scripting language. This means that in-game scripting is not technically limited to functions provided by the game - we can extend it with operators and functions that are not ever seen in CA's scripting code. Although this doesn't offer us much in terms of practicality for simple scripting, it can be put to great use for those interested in more advanced scripting.

    Case sensitivity:
    All Lua functions and objects are case-sensitive. That is, CampaignUI is not equal to campaignui, campaignUi or anything like that. So a mistake with case will cause your script to malfunction.

    Whitespace:
    Lua ignores whitespace, where applicable. So 3 > 1 is the same as 3>1 is the same as 3> 1

    Key Words:
    Click to view content: 


    • Strings: Strings are sentences containing numbers, characters or symbols. They begin and end with quotation marks. Eg:
      Code:
      "Hello World"
    • Boolean Values: Boolean values can only be true or false
    • Type: The type of a variable can either be boolean, function, nil, number, string, table, thread or userdata. If any function requests a variable of a certain type, and a variable of a different type is passed to it it may well cause a CTD.
    • int: Short for integer. (Negative or positive whole number)
    • Comments:Comments are part of the scripting file that will be ignored by the game. A normal comment begins with "--" (without the quotes) and lasts the length of the line. A long comment begins with "--[[" (without the quotes) and ends with "]]--" (without the quotes). Long comments comment everything inside them out, so can be used to efficiently comment out large blocks of code. Examples:
      Code:
      --I'm a short comment
      --[[And 
      I'm
      A
      Long
      Comment ]]--




    Basic Lua Operators & Statements:
    Click to view content: 

    Arithmetic Operators:
    Click to view content: 


    • Addition:
      +
    • Subtraction:
      -
    • Multiplication:
      *
    • Division:
      /
    • Exponentiation:
      ^



    Relational Operators:
    Click to view content: 


    • Equal to:
      ==
    • Not equal to:
      ~=
    • Less than:
      <
    • Less than or equal to:
      <=
    • Greater than:
      >
    • Greater than or equal to:
      >=


    Logical Operators:
    Note: Logical operators are sometimes referred to as Boolean Operators, but they can be given non-boolean values.
    Click to view content: 


    • and
      and takes two or more arguments and only returns true if they are all true
    • or
      or only gives a false result if both of it's arguments are false
    • not
      not is, simply put, a logical no. Putting not before a statement that would otherwise return true, will make it return false and vice versa.



    Basic Statements:
    Click to view content: 


    • if
    • while
      while is a type of loop. I'll not be explaining loops here, you can find tutorials on them with google very easily.
    • for
      Another type of loop.



    Backslash Escaping (Very important for logging):
    Click to view content: 
    Backslash escaping allows the user to do things inside strings that would normally be quite akward to do. It is a very simple method of manipulating text. The following list contains the most relevant escape sequences used in game scripting:

    • \n - Newline. This moves the following text onto a new line.
    • \t - Tab. This tabs horizontally.
    • \\ - Backslash. This allows a single backslah to be inserted into the text.
    • \" - double quote. This allows a double quote to be inserted without ending the string.



    Concatenation:
    Click to view content: 
    Lua's string concatenation operator is written as follows:
    Code:
    ..
    That's two periods with no spaces between them. The whitespace rule does not apply here as this is an operator, which is easy to forget.
    It is used for splicing strings together, as follows(output is listed respectively in the next spoiler):
    Code:
    print("Hello".."World")
    
    ScriptORamaVariable = "World"
    print("Hello "..ScriptORamaVariable)
    And the output:

    Code:
    HelloWorld
    Hello World
    Notice that it doesn't put spaces between arguments there for you (the first example), so it has to be done manually(the second example).






    I.2 Effects
    The game's general effect library not specifically geared towards scripting. From here you can do stuff like edit cash amounts, edit traits + ancillaries etc.
    Click to view content: 

    The following functions are documented here:
    adjust_treasury
    ancillary
    remove_ancillary
    trait
    remove_trait
    historical_event



    Documentation:

    adjust_treasury(int amount, context)
    effect.adjust_treasury will change the treasury of a certain faction.
    Spoiler Alert, click show to read: 

    Parameters: Amount of money (int), context

    Example:
    Code:
    events.FactionTurnStart[#events.FactionTurnStart+1] =
    function (context)
        effect.adjust_treasury(-1000,context)
    end


    ancillary(Ancillary name (string), Chance of ancillary being added (int), context)
    effect.ancillary() will add the given ancillary to the selected character.
    Spoiler Alert, click show to read: 

    Parameters: Ancillary name (string), % Chance of ancillary being added (int), context

    Example:
    Code:
    events.CharacterTurnEnd[#events.CharacterTurnEnd+1] = 
    function (context)
        effect.ancillary("Anc_Balloonist", 100,  context)
    end


    remove_ancillary(Ancillary name (string), context)
    effect.remove_ancillary() will remove the given ancillary from the selected character.
    Spoiler Alert, click show to read: 

    Parameters: Ancillary name (string), context

    Example:
    Code:
    events.CharacterTurnEnd[#events.CharacterTurnEnd+1] = 
    function (context)
        effect.remove_ancillary("Anc_Balloonist", context)
    end


    trait(Trait name(string), Game entity type(string), Trait points to add(int), % Chance of trait being added(int), context)
    effect.trait() will add the given trait to the selected game entity.
    Spoiler Alert, click show to read: 

    Parameters: Trait name(string), Game entity type(string), Trait points to add(int), % Chance of trait being added(int), context

    Example:
    Code:
    events.CharacterTurnEnd[#events.CharacterTurnEnd+1] = 
    function (context)
        effect.trait("C_Admiral_Attacker_Good", "agent", 2, 12, context)
    end


    remove_trait(Trait name(string), POSSIBLY NEEDS: Game entity type(string), context)
    effect.remove_trait() will remove the given trait from the selected game entity.
    Spoiler Alert, click show to read: 

    Parameters: Trait name(string), POSSIBLY NEEDS: Game entity type(string), context

    Example:
    Code:
    events.CharacterTurnEnd[#events.CharacterTurnEnd+1] = 
    function (context)
        effect.remove_trait("C_Admiral_Attacker_Good", "agent", context)
    end


    historical_event(Event key(string), context)
    effect.historical_event() will trigger a historic event.
    Spoiler Alert, click show to read: 

    Parameters: Event key(string), context
    Example:
    Code:
    events.HistoricalEvents[#events.HistoricalEvents+1] = 
    function (context)
        effect.historical_event("luddite_movement", context)
    end





    I.3 Campaign UI
    CampaignUI seems to have loads of useful functions (see the list above). The main advantage of using CamaignUI is that the functions often don't require any arguments and return boolean values, making them very useable. CUI's main use is to retrieve data from the game - it has very little use for actually changing things.
    Click to view content: 

    The following functions are documented here:
    CurrentSeasonString
    CurrentTurn
    CurrentYear
    DisplayingTurns
    EndTurn
    EntityTypeSelected
    FactionDetails
    IsPlayersTurn
    InitialiseRegionInfoDetails
    InitialiseCharacterDetails
    InitialiseUnitDetails
    IsCharacterPlayerControlled
    PlayerFactionId
    PrestigeDetails
    RetrieveDiplomacyDetails
    RetrieveDiplomaticOpinions
    RetrieveDiplomaticStanceString
    RegionsOwnedByFaction
    RetrieveFactionRegionList
    RetrieveFactionMilitaryForceLists



    Documentation:

    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

    Example:
    Code:
    CampaignUI.EntityTypeSelected()
    Will return a table containing this info:
    Code:
      Character: boolean: true
      Unit: boolean: false
      Slot: boolean: false
      Settlement: boolean: false
      Entity: userdata
        type: string: Pointer<CHARACTER>
        __tostring: function
        __eq: function
      LocalPlayerOwned: boolean: true
      Fort: boolean: false


    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


    IsPlayersTurn()
    IsPlayersTurn returns a boolean stating the obvious
    Click to view content: 
    Returns: true or false depending on whether or not it is the player's turn.
    Example:
    Code:
    CampaignUI.IsPlayersTurn()



    InitialiseCharacterDetails(<Character Pointer> character)
    Returns all stored info on a character from the provided character pointer.
    Click to view content: 
    Arguments: <Character Pointer> character: The address of the character you want info on.

    Returns: Table containing all character information

    Example:
    Code:
    events.ComponentLClickUp[#events.ComponentLClickUp+1] = function(context)
    	local ETS = CampaignUI.EntityTypeSelected()
    	if ETS.Character then
    		charDetails = CampaignUI.InitialiseCharacterDetails(ETS.Entity)
    	end
    end
    Will return a table containing this info:
    Code:
    	ActionPointsPerTurn	24
    	Attributes	table: 3A5A50C8
    			morale_sea	table: 4588DD98
    				Value	-1
    				AttributeName	Morale
    				PipPath	PLACEHOLDER
    			research	table: 45873C98
    				Value	-1
    				AttributeName	Research Skill
    				PipPath	data/ui/campaign ui/pips//skill_research.tga
    			land_siege_engineering	table: 4590AA08
    				Value	-1
    				AttributeName	Siege engineering
    				PipPath	PLACEHOLDER
    			movement_points_land	table: 4591BD68
    				Value	1
    				AttributeName	movement_points_land_name
    				PipPath	PLACEHOLDER
    			management	table: 3A58E008
    				Value	-1
    				AttributeName	Management Skill
    				PipPath	data/ui/campaign ui/pips//skill_managing.tga
    			PrimaryAttributePath	data/ui/campaign ui/pips//skill_command.tga
    			PrimaryAttributeName	Command on Land
    			zeal	table: 4590A888
    				Value	-1
    				AttributeName	Religious Zeal
    				PipPath	data/ui/campaign ui/pips//skill_zeal.tga
    			subterfuge	table: 16537BC0
    				Value	-1
    				AttributeName	Subterfuge Skill
    				PipPath	data/ui/campaign ui/pips//skill_spying.tga
    			duelling_swords	table: 45879D38
    				Value	-1
    				AttributeName	Sword duelling
    				PipPath	data/ui/campaign ui/pips//skill_swordfighting.tga
    			duelling_pistols	table: 4588D2F8
    				Value	-1
    				AttributeName	Pistol duelling
    				PipPath	data/ui/campaign ui/pips//skill_shooting.tga
    			morale_land	table: 4591BC08
    				Value	1
    				AttributeName	Morale
    				PipPath	PLACEHOLDER
    			trade	table: 4591E7A8
    				Value	-1
    				AttributeName	Trade
    				PipPath	PLACEHOLDER
    			PrimaryLevel	8
    			land_defence_engineering	table: 45882118
    				Value	-1
    				AttributeName	Land defence engineering
    				PipPath	PLACEHOLDER
    			command_sea	table: 16537C40
    				Value	-1
    				AttributeName	Command at Sea
    				PipPath	data/ui/campaign ui/pips//skill_naval.tga
    			command_land	table: 16552780
    				Value	5
    				AttributeName	Command on Land
    				PipPath	data/ui/campaign ui/pips//skill_command.tga
    	Title	 
    	Flag	data\ui\flags\britain/portrait_flags.tga
    	Traits	table: 45936828
    			1	table: 4591BAA8
    				ExplanationText	This man has had too little to do, and fallen in with the wrong kind of fellows.
    				IconFilename	data/ui/campaign ui/pips/effect_characters.tga
    				Name	Unsavoury Bawd
    				Effects	table: 1654AAE0
    				ColourText	This man delights in meretricious company, relishing even the loss of reputation.
    				AttributeEffects	table: 3A64C4F8
    				RemovalText	It will take years of self-denial and hard work to improve this man's sad lack of manners and character.
    			2	table: 45978330
    				ExplanationText	This is the result of repeated victories and can be improved further.
    				IconFilename	data/ui/campaign ui/pips/effect_army.tga
    				Name	Great General
    				Effects	table: 16537CE0
    				ColourText	This man is properly counted among the great captains in battle.
    				AttributeEffects	table: 459198C8
    				RemovalText	This trait is a permanent feature of this man's character.
    			3	table: 459198A8
    				ExplanationText	This general has enjoyed several victories while leading a substantial  cavalry force.
    				IconFilename	data/ui/campaign ui/pips/effect_army.tga
    				Name	Riding Master
    				Effects	table: 45919848
    				ColourText	This general has all the dash and fire one would expect of a gallant cavalryman!
    				AttributeEffects	table: 45919708
    				RemovalText	Many defeats while leading a large number of cavalry may reduce this ability.
    			4	table: 45919628
    				ExplanationText	This general has not hestitated to become personally involved in combat.
    				IconFilename	data/ui/campaign ui/pips/effect_army.tga
    				Name	Steady Under Fire
    				Effects	table: 459195C8
    				ColourText	"I say, those chaps over there mean to kill us! What absolute rotters! Shall we have at them?"
    				AttributeEffects	table: 459194E8
    				RemovalText	Running from battle will probably wipe away this general's reputation for bravery.
    	Effects	table: 458757F8
    			1	table: 4587ADD8
    				Icon	data/ui/campaign ui/pips/skill_command.tga
    				Tooltip	+2 to Command when leading cavalry units
    			2	table: 4591E9E8
    				Icon	data/ui/campaign ui/pips/effect_public_order.tga
    				Tooltip	-1 happiness (lower classes)
    			3	table: 07DC3B40
    				Icon	data/ui/campaign ui/pips/effect_army.tga
    				Tooltip	+1 to morale in battles
    	unit	table: 45919448
    			Charge	14
    			UnitLimit	0
    			Reloading	0
    			IsFixedArtillery	false
    			FactionColour	table: 45919368
    				b	0
    				g	0
    				r	222
    			Firepower	0
    			Manoeuvrability	manoeuverability_medium
    			InTransit	false
    			RecruitCost	800
    			CommanderType	0
    			Accuracy	0
    			Id	unit27
    			Defence	10
    			knowledge_mask	15
    			PromotionCost	800
    			IsArtillery	false
    			Replenished	false
    			Men	32
    			Ammunition	0
    			UpkeepCost	44
    			InfoPic	data/ui/units/info/euro_heavy_cavalry
    			Replenishable	false
    			UnitRecord	table: 459197E8
    				Ammunition	0
    				RecruitTime	1
    				UpkeepCost	60
    				InfoPic	data/ui/units/info/euro_heavy_cavalry
    				Class	General
    				Range	0
    				IsFixedArtillery	false
    				UnitLimit	0
    				MPCost	410
    				Key	euro_generals_bodyguard
    				IsArtillery	false
    				IsNaval	false
    				Experience	0
    				RecruitCost	800
    				Men	32
    				Defence	10
    				Reloading	0
    				Melee	9
    				Accuracy	0
    				Firepower	0
    				DisplayNumber	32
    				ClassID	12
    				Charge	14
    				Guns	0
    				Description	These tough warriors and soldiers have only one task: keeping their commander alive and well in the swirling chaos of battle. 
    				Name	General's Bodyguard
    				Morale	10
    				SiegeUnit	false
    				Icon	data/ui/units/icons/Euro_Heavy_Cavalry
    				LongDescription	
    
    A general can only do his duty properly if these men keep rough and unpleasant fellows from interrupting his calm deliberations about how to kill as many of the enemy as possible for as little loss as possible.
    
    Only the most loyal and fiercest fighters are assigned to a general’s bodyguard. Good manners are a bonus, of course, but a strong sword arm and a deadly aim are more use! Their equipment is generally of the finest quality, and their pay is often supplemented from the general’s own pocket: they have a sound financial interest in keeping him alive, as well as their honour in carrying out a duty successfully!
    				MPCategory	1
    			ExistingUnit	true
    			DisplayAsUnit	true
    			RegimentName	
    			LongDescription	
    
    A general can only do his duty properly if these men keep rough and unpleasant fellows from interrupting his calm deliberations about how to kill as many of the enemy as possible for as little loss as possible.
    
    Only the most loyal and fiercest fighters are assigned to a general’s bodyguard. Good manners are a bonus, of course, but a strong sword arm and a deadly aim are more use! Their equipment is generally of the finest quality, and their pay is often supplemented from the general’s own pocket: they have a sound financial interest in keeping him alive, as well as their honour in carrying out a duty successfully!
    			Attributes	table: 45919328
    				PrimaryLevel	8
    				PrimaryAttributePath	data/ui/campaign ui/pips//skill_command.tga
    			Speed	0
    			UniformColour	table: 45919348
    				b	16
    				g	22
    				r	192
    			Icon	data/ui/units/icons/Euro_Heavy_Cavalry
    			NeedsRepair	false
    			ActionPoints	29
    			RepairCost	0
    			Melee	9
    			IsNaval	false
    			ShowAsCharacter	true
    			Portrait	data/ui/portraits/european/Cards/general/old/003.tga
    			Description	These tough warriors and soldiers have only one task: keeping their commander alive and well in the swirling chaos of battle. 
    			Range	0
    			HullStrength	0
    			Morale	10
    			Guns	0
    			Address	Pointer<UNIT> (0x03ae16838)
    			Traits	table: 45919388
    			Experience	0
    			Name	General's Bodyguard
    			CommandersName	John Churchill
    	IsMilitary	true
    	FactionColour	table: 3A49C2F0
    			b	0
    			g	0
    			r	222
    	ShowAsCharacter	true
    	PosX	-5.5
    	Abilities	table: 45879A38
    			can_research	false
    			can_assassinate	false
    			can_attack_naval	false
    			can_build_religious	false
    			can_sabotage_army	false
    			can_attack_land	true
    			can_receive_duel	false
    			can_build_fort	true
    			can_duel	false
    			can_convert	false
    			can_sabotage	false
    			can_spy	false
    	Soldiers	412
    	Units	4
    	CommanderType	0
    	ActionPoints	24
    	PosY	367.64001464844
    	AgentType	General
    	IsNaval	false
    	SmallFlag	data\ui\flags\britain/small.tga
    	UniformColour	table: 45970DD0
    			b	16
    			g	22
    			r	192
    	MaskImage	
    	TechImage	
    	Playable	true
    	CardImage	data/ui/portraits/european/Cards/general/old/003.tga
    	InfoImage	data/ui/portraits/european/Info/general/old/003.jpg
    	Address	Pointer<CHARACTER> (0x03b55c168)
    	Location	England
    	Name	John Churchill
    	Age	50
    	Ancillaries	table: 459194A8


    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)
    Spoiler Alert, click show to read: 
    Arguments: Region pointer

    Returns: Region details table

    Example:
    Code:
    tab = CampaignUI.RegionsOwnedByFaction("france")
        details = CampaignUI.InitialiseRegionInfoDetails(tab[1].Address)
    Will return a table containing this info:
    Code:
    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




    InitialiseUnitDetails(<Unit Pointer> character)
    Returns all stored info on a unit from the provided character pointer.
    Click to view content: 
    Arguments: <Unit Pointer> unit: The address of the unit you want info on.

    Returns: Table containing all unit information

    Example:
    Code:
    events.ComponentLClickUp[#events.ComponentLClickUp+1] = function(context)
    	local ETS = CampaignUI.EntityTypeSelected()
    	if ETS.Unit then
    		unitDetails = CampaignUI.InitialiseUnitDetails(ETS.Entity)
    	end
    end
    Will return a table containing this info:
    Code:
    Unit table
    Charge	8
    UnitLimit	0
    CharacterPtr	Pointer<CHARACTER> (0x03adba548)
    Reloading	10
    IsFixedArtillery	false
    FactionColour	table: 45936EC8
    		b	0
    		g	0
    		r	222
    Firepower	0
    Manoeuvrability	manoeuverability_medium
    InTransit	false
    RecruitCost	700
    CommanderType	5
    Accuracy	25
    Id	unit31
    Defence	9
    knowledge_mask	15
    PromotionCost	800
    IsArtillery	false
    Replenished	false
    Men	160
    Ammunition	15
    UpkeepCost	126
    InfoPic	data/ui/units/info/Euro_Militia_Infantry_info_infm
    Replenishable	false
    UnitRecord	table: 16554840
    		Ammunition	15
    		RecruitTime	1
    		UpkeepCost	170
    		InfoPic	data/ui/units/info/Euro_Militia_Infantry_info_infm
    		Class	Militia
    		Range	70
    		IsFixedArtillery	false
    		UnitLimit	0
    		MPCost	520
    		Key	euro_militia_infantry
    		IsArtillery	false
    		IsNaval	false
    		Experience	0
    		RecruitCost	700
    		Men	160
    		Defence	9
    		Reloading	10
    		Melee	4
    		Accuracy	25
    		Firepower	0.75
    		DisplayNumber	160
    		ClassID	20
    		Charge	8
    		Guns	0
    		Description	These musket-armed troops are recruited to defend their own locality, not carry the war to an enemy’s land. 
    		Name	Militia
    		Morale	4
    		SiegeUnit	true
    		Icon	data/ui/units/icons/Euro_Militia_Infantry_icon_infm
    		LongDescription	
    
    Militia or provincial troops are commonly held to be inferior to regular soldiers and, although they are trained to use the same tactics as marching regiments of the line, there is some truth in this assertion. Militia are expected to act as reassuring presence, and sometimes as a police force in suppressing local disturbances.
    
    Historically, it was not unusual for militia to be locals recruited as part-time soldiers while retaining their day jobs and trades. In Britain, for example, service in the militia was seen as a good idea: you not only looked very patriotic for volunteering, but you could not be sent overseas! For ambitious would-be officers, there was a hidden financial benefit to joining the militia. A commander who could persuade his men to transfer to the army with him would not have to pay the cost of his regular commission.
    		MPCategory	2
    ExistingUnit	true
    RegimentName	4th Regiment of Militia
    LongDescription	
    
    Militia or provincial troops are commonly held to be inferior to regular soldiers and, although they are trained to use the same tactics as marching regiments of the line, there is some truth in this assertion. Militia are expected to act as reassuring presence, and sometimes as a police force in suppressing local disturbances.
    
    Historically, it was not unusual for militia to be locals recruited as part-time soldiers while retaining their day jobs and trades. In Britain, for example, service in the militia was seen as a good idea: you not only looked very patriotic for volunteering, but you could not be sent overseas! For ambitious would-be officers, there was a hidden financial benefit to joining the militia. A commander who could persuade his men to transfer to the army with him would not have to pay the cost of his regular commission.
    DisplayAsUnit	false
    Speed	0
    UniformColour	table: 16554820
    		b	16
    		g	22
    		r	192
    Icon	data/ui/units/icons/Euro_Militia_Infantry_icon_infm
    NeedsRepair	false
    ActionPoints	19
    RepairCost	0
    Melee	4
    Traits	table: 4592D2C8
    ShowAsCharacter	false
    Portrait	
    Description	These musket-armed troops are recruited to defend their own locality, not carry the war to an enemy’s land. 
    Range	70
    HullStrength	0
    Morale	4
    Name	Militia
    Address	Pointer<UNIT> (0x03ae16c18)
    IsNaval	false
    Experience	0
    Guns	0
    CommandersName	Hilario Fielding


    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
    Spoiler Alert, click show to read: 

    Returns: Prestige details table

    Example:
    Code:
    CampaignUI.PrestigeDetails()
    Will return a table containing this info:
    Code:
     scale: number: 34
      factions: table
        1: table
          faction_colour: table
            b: number: 0
            g: number: 0
            r: number: 0.8705883026123
          history: table
            1: table
              military: number: 5
              overall: number: 30
              enlightenment: number: 5
              naval: number: 10
              economics: number: 10
            2: table
              military: number: 5
              overall: number: 30
              enlightenment: number: 5
              naval: number: 10
              economics: number: 10
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: Great Britain
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: britain
          flag_path: string: data\ui\flags\britain
          is_ally: boolean: false
        2: table
          faction_colour: table
            b: number: 0.94117653369904
            g: number: 1
            r: number: 1
          history: table
            1: table
              military: number: 18
              overall: number: 34
              enlightenment: number: 4
              naval: number: 5
              economics: number: 7
            2: table
              military: number: 18
              overall: number: 34
              enlightenment: number: 4
              naval: number: 5
              economics: number: 7
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: France
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: france
          flag_path: string: data\ui\flags\france
          is_ally: boolean: false
        3: table
          faction_colour: table
            b: number: 0.33725491166115
            g: number: 0.56470590829849
            r: number: 0.64705884456635
          history: table
            1: table
              military: number: 17
              overall: number: 24
              enlightenment: number: 0
              naval: number: 0
              economics: number: 7
            2: table
              military: number: 17
              overall: number: 24
              enlightenment: number: 0
              naval: number: 0
              economics: number: 7
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: Austria
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: austria
          flag_path: string: data\ui\flags\austria
          is_ally: boolean: true
        4: table
          faction_colour: table
            b: number: 0.11372549831867
            g: number: 0.5137255191803
            r: number: 1
          history: table
            1: table
              military: number: 0
              overall: number: 23
              enlightenment: number: 5
              naval: number: 5
              economics: number: 13
            2: table
              military: number: 0
              overall: number: 23
              enlightenment: number: 5
              naval: number: 5
              economics: number: 13
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: United Provinces
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: netherlands
          flag_path: string: data\ui\flags\netherlands_republic
          is_ally: boolean: true
        5: table
          faction_colour: table
            b: number: 0.0039215688593686
            g: number: 0.85098046064377
            r: number: 0.99215692281723
          history: table
            1: table
              military: number: 5
              overall: number: 23
              enlightenment: number: 0
              naval: number: 8
              economics: number: 10
            2: table
              military: number: 5
              overall: number: 23
              enlightenment: number: 0
              naval: number: 8
              economics: number: 10
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: Spain
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: spain
          flag_path: string: data\ui\flags\spain
          is_ally: boolean: false
        6: table
          faction_colour: table
            b: number: 0.32549020648003
            g: number: 0.19215688109398
            r: number: 0
          history: table
            1: table
              military: number: 16
              overall: number: 16
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            2: table
              military: number: 16
              overall: number: 16
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: Prussia
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: prussia
          flag_path: string: data\ui\flags\prussia
          is_ally: boolean: false
        7: table
          faction_colour: table
            b: number: 0.21960785984993
            g: number: 0.18823531270027
            r: number: 0.62745100259781
          history: table
            1: table
              military: number: 10
              overall: number: 13
              enlightenment: number: 0
              naval: number: 0
              economics: number: 3
            2: table
              military: number: 10
              overall: number: 13
              enlightenment: number: 0
              naval: number: 0
              economics: number: 3
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: Poland-Lithuania
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: poland_lithuania
          flag_path: string: data\ui\flags\poland_lithuania
          is_ally: boolean: false
        8: table
          faction_colour: table
            b: number: 0
            g: number: 0
            r: number: 0.52549022436142
          history: table
            1: table
              military: number: 6
              overall: number: 16
              enlightenment: number: 0
              naval: number: 0
              economics: number: 10
            2: table
              military: number: 6
              overall: number: 16
              enlightenment: number: 0
              naval: number: 0
              economics: number: 10
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: Ottoman Empire
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: ottomans
          flag_path: string: data\ui\flags\ottomans
          is_ally: boolean: false
        9: table
          faction_colour: table
            b: number: 0.13333334028721
            g: number: 0.41568630933762
            r: number: 0.13333334028721
          history: table
            1: table
              military: number: 16
              overall: number: 16
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            2: table
              military: number: 16
              overall: number: 16
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: Russia
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: russia
          flag_path: string: data\ui\flags\russia
          is_ally: boolean: false
        10: table
          faction_colour: table
            b: number: 0.60000002384186
            g: number: 0.35686275362968
            r: number: 0.05882353335619
          history: table
            1: table
              military: number: 11
              overall: number: 12
              enlightenment: number: 0
              naval: number: 1
              economics: number: 0
            2: table
              military: number: 11
              overall: number: 12
              enlightenment: number: 0
              naval: number: 1
              economics: number: 0
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: Sweden
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: sweden
          flag_path: string: data\ui\flags\sweden
          is_ally: boolean: false
        11: table
          faction_colour: table
            b: number: 0.10980392992496
            g: number: 0.41960787773132
            r: number: 0.70980393886566
          history: table
            1: table
              military: number: 7
              overall: number: 7
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            2: table
              military: number: 7
              overall: number: 7
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: Maratha Confederacy
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: maratha
          flag_path: string: data\ui\flags\maratha
          is_ally: boolean: false
        12: table
          faction_colour: table
            b: number: 0.10588236153126
            g: number: 0.41960787773132
            r: number: 0.37647062540054
          history: table
            1: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            2: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            3: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            4: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            5: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
            6: table
              military: number: 0
              overall: number: 0
              enlightenment: number: 0
              naval: number: 0
              economics: number: 0
          name: string: Mughal Empire
          is_enemy: boolean: false
          is_neighbouring: boolean: false
          key: string: mughal
          flag_path: string: data\ui\flags\mughal
          is_ally: boolean: false


    RetrieveDiplomacyDetails(Faction Key (string))
    RetrieveDiplomacyDetails returns a table with diplomacy details of the given faction.
    Click to view content: 
    Returns: A table with diplomacy details of the faction.
    Example:
    Code:
    RetrieveDiplomacyDetails("france")
    Example Returns:
    Code:
    TradeRights    table: 1AD793B8
                    wurttemberg    table: 1AD79518
                            Flag    data\ui\flags\wurttemberg/small.tga
                            Name    Baden-Württemberg
                            Label    wurttemberg
                    italy_kingdom    table: 1AD79458
                            Flag    data\ui\flags\italy_kingdom/small.tga
                            Name    Kingdom of Italy
                            Label    italy_kingdom
                    netherlands    table: 1AD7FF58
                            Flag    data\ui\flags\united_netherlands/small.tga
                            Name    Batavian Republic
                            Label    netherlands
                    swiss_confederation    table: 1AD79478
                            Flag    data\ui\flags\swiss_confederation/small.tga
                            Name    Swiss Confederation
                            Label    swiss_confederation
                    spain    table: 1AD7FDD8
                            Flag    data\ui\flags\spain/small.tga
                            Name    Spain
                            Label    spain
    AtWar    table: 1AD79378
                    austria    table: 1AD794B8
                            Flag    data\ui\flags\austria/small.tga
                            Name    Austria
                            Label    austria
                    sicily    table: 1AD795B8
                            Flag    data\ui\flags\naples_sicily/small.tga
                            Name    Kingdom of Sicily
                            Label    sicily
                    naples    table: 1AD79558
                            Flag    data\ui\flags\naples/small.tga
                            Name    Kingdom of Naples
                            Label    naples
                    britain    table: 1AD794D8
                            Flag    data\ui\flags\britain/small.tga
                            Name    Great Britain
                            Label    britain
                    sweden    table: 1AD7FDF8
                            Flag    data\ui\flags\sweden/small.tga
                            Name    Sweden
                            Label    sweden
                    russia    table: 1AD79498
                            Flag    data\ui\flags\russia/small.tga
                            Name    Russia
                            Label    russia
    Protectorates    table: 1AD793F8
    ProtectorOf    table: 1AD79418
    Allies    table: 1AD79398
                    wurttemberg    table: 1AD794F8
                            Flag    data\ui\flags\wurttemberg/small.tga
                            Name    Baden-Württemberg
                            Label    wurttemberg
                    bavaria    table: 1AD79578
                            Flag    data\ui\flags\bavaria/small.tga
                            Name    Bavaria
                            Label    bavaria
                    italy_kingdom    table: 1AD79438
                            Flag    data\ui\flags\italy_kingdom/small.tga
                            Name    Kingdom of Italy
                            Label    italy_kingdom
                    netherlands    table: 1AD799B8
                            Flag    data\ui\flags\united_netherlands/small.tga
                            Name    Batavian Republic
                            Label    netherlands
                    swiss_confederation    table: 1AD79538
                            Flag    data\ui\flags\swiss_confederation/small.tga
                            Name    Swiss Confederation
                            Label    swiss_confederation
                    spain    table: 1AD799D8
                            Flag    data\ui\flags\spain/small.tga
                            Name    Spain
                            Label    spain


    RetrieveDiplomaticOpinions(Faction Key 1 (string), Faction Key 2(string))
    RetrieveDiplomaticOpinions returns the diplomatic opinions of two factions.
    Click to view content: 
    Returns: A string stating the diplomatic opinions of the given faction
    Example:
    Code:
    CampaignUI.RetrieveDiplomaticOpinions("france", "britain")
    Example Returns:
    Code:
    Hostile


    RetrieveDiplomaticStanceString(Faction Key 1 (string), Faction Key 2(string))
    RetrieveDiplomaticStanceString returns the diplomatic stance of two factions.
    Click to view content: 
    Returns: a string stating the diplomatic stance of the two given factions (at war, allied etc)
    Example:
    Code:
    CampaignUI.RetrieveDiplomaticStanceString("france", "britain")
    Example Returns:
    Code:
    at war


    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

    Example:
    Code:
    CampaignUI.RetrieveFactionMilitaryForceLists("france",true)
    Will return a table containing this info:
    Code:
    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
      ...



    Last edited by T.C.; June 16, 2013 at 06:58 AM.

  2. #2

    Default Re: Script-o-Rama 2

    I.3 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: 

    The following functions are documented here:
    add_exclusion_zone
    add_restricted_unit_record
    add_restricted_building_level_record
    disable_movement_for_faction
    enable_movement_for_faction
    episodic_attack
    episodic_defend
    force_diplomacy
    grant_faction_handover
    grant_unit
    remove_restricted_building_level_record
    remove_restricted_unit_record
    show_shroud
    spawn_town_level
    trigger_custom_mission



    Documentation:

    add_exclusion_zone(left(int), top(int), right(int), bottom(int), exclude_armies(bool), exclude_navies(bool), exclude_agents(bool), faction key(string))
    add_exclusion_zone adds a no-go area for the AI.
    Spoiler Alert, click show to read: 

    Parameters: left(int), top(int), right(int), bottom(int), exclude_armies(bool), exclude_navies(bool), exclude_agents(bool), faction key(string)

    Example:
    Code:
    scripting.game_interface:add_exclusion_zone(-100, 100, 100, -100, true, true, true, "britain")



    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)

    Example:
    Code:
    scripting.game_interface:add_restricted_unit_record("euro_expat_infantry_regiments_etrangeres")


    add_restricted_building_level_record(building key(string))
    add_restricted_building_level_record allows you to remove a building from being available for building world-wide.
    Spoiler Alert, click show to read: 

    Parameters: Building key as string (as it appears in the db)

    Example:
    Code:
    scripting.game_interface:add_restricted_building_level_record("tFactory1_manufactory")


    disable_movement_for_faction(Faction Key(String))
    disable_movement_for_faction freezes movement for the specified faction
    Spoiler Alert, click show to read: 

    Parameters: Faction key as string (as it appears in the db)

    Example:
    Code:
    scripting.game_interface:disable_movement_for_faction("france")


    enable_movement_for_faction(Faction Key(String))
    enable_movement_for_faction allows movement for the faction previously froze.
    Spoiler Alert, click show to read: 

    Parameters: Faction key as string (as it appears in the db)

    Example:
    Code:
    scripting.game_interface:enable_movement_for_faction("france")


    episodic_attack(faction key (string), target faction(string))
    episodic_attack advises the AI to attack a faction. It is largely untested, results may vary.
    Spoiler Alert, click show to read: 

    Parameters: faction key (string), target faction(string)

    Example:
    Code:
    scripting.game_interface:episodic_attack("france", "britain")


    episodic_defend(faction key (string), region(string))
    episodic_defend advises the AI to defend a region. It is largely untested, results may vary.
    Spoiler Alert, click show to read: 

    Parameters: faction key (string), region(string)

    Example:
    Code:
    scripting.game_interface:episodic_defend("france", "eur_norway")


    force_diplomacy(faction_key(string), target_faction(string), diplomatic option(string), can offer (bool), will accept(bool))
    force_diplomacy forces a certain stance from one faction towards another
    Spoiler Alert, click show to read: 

    Parameters: faction_key(string), target_faction(string), diplomatic option(string), can offer (bool), will accept(bool)

    Example:
    Code:
    scripting.game_interface:force_diplomacy("france", "britain", "war" true, true)



    grant_faction_handover(recipient faction key(string), handed over faction key(string), first possible turn(int), last possible turn(int), context)
    grant_faction_handover hands over the specified faction to the specified recipient.
    Spoiler Alert, click show to read: 

    Parameters: recipient faction key(string), handed over faction key(string), first possible turn(int), last possible turn(int), context

    Example:
    Code:
    scripting.game_interface:grant_faction_handover("britain", "france", 1, 2, context)


    grant_unit(location(string), unit to grant(string))
    Spawns the given unit at the given location. The location must be a settlement.
    Spoiler Alert, click show to read: 

    Parameters: location(string), unit to grant(string)

    Example:
    Code:
    scripting.game_interface:grant_unit("settlement:ita_milano:milan", "Inf_Light_Lombardy-Cisalpine_Legion")


    remove_restricted_building_level_record(building key(string))
    remove_restricted_building_level_record removes the restriction on a building record that was previously set with add_restricted_building_level_record
    Spoiler Alert, click show to read: 

    Parameters: Building key as string (as it appears in the db)

    Example:
    Code:
    scripting.game_interface:remove_restricted_building_level_record("tFactory1_manufactory")


    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)

    Example:
    Code:
    scripting.game_interface:remove_restricted_unit_record("euro_expat_infantry_regiments_etrangeres")


    show_shroud(true/false)
    show_shroud disables or enables the fog of war
    Spoiler Alert, click show to read: 

    Parameters: true/ false

    Example:
    Code:
    scripting.game_interface:show_shroud(false)


    spawn_town_level(region key (string), level(int), notification(bool))
    spawn_town_level spawns a town up to the specified level.
    Spoiler Alert, click show to read: 

    Parameters: region key (string), level(int), trigger notification(bool)

    Example:
    Code:
    scripting.game_interface:spawn_town_level("virginia", 1, true)


    trigger_custom_mission(mission id (string), faction key(string), mission type(string), turn limit(int), parameters(string), heading key(string), description key(string), reward key(string), reward money(int), reward faction key(string), context)
    trigger_custom_mission triggers a custom mission.
    Spoiler Alert, click show to read: 

    Parameters: mission id (string), faction key(string), mission type(string), turn limit(int), parameters(string), heading key(string), description key(string), reward key(string), reward money(int), reward faction key(string), context

    Example:
    Code:
    sscripting.game_interface:trigger_custom_mission("eur_prussia_alliance_austria","prussia","forge_alliance", 0, "austria", "mission_text_text_eur_prussia_alliance_austria_heading", "mission_text_text_eur_prussia_alliance_austria_text",
    "", 0, "", context






    I.5 Events
    This is a list of hookable events as shown in the events.lua file in the data pack and certain patch packs. Events are not explicitly documented as they are mostly self-explanatory. If you have any questions on any of them just ask.

    Click to view content: 
    AdviceDismissed
    AdviceFinishedTrigger
    AdviceIssued
    AdviceSuperseded
    ArmySabotageAttemptSuccess
    AssassinationAttemptSuccess
    BattleBoardingActionCommenced
    BattleCommandingShipRouts
    BattleCommandingUnitRouts
    BattleCompleted
    BattleConflictPhaseCommenced
    BattleDeploymentPhaseCommenced
    BattleFortPlazaCaptureCommenced
    BattleShipAttacksEnemyShip
    BattleShipCaughtFire
    BattleShipMagazineExplosion
    BattleShipRouts
    BattleShipRunAground
    BattleShipSailingIntoWind
    BattleShipSurrendered
    BattleUnitAttacksBuilding
    BattleUnitAttacksEnemyUnit
    BattleUnitAttacksWalls
    BattleUnitCapturesBuilding
    BattleUnitDestroysBuilding
    BattleUnitRouts
    BattleUnitUsingBuilding
    BattleUnitUsingWall
    BuildingCardSelected
    BuildingCompleted
    BuildingConstructionIssuedByPlayer
    BuildingInfoPanelOpenedCampaign
    CameraMoverCancelled
    CameraMoverFinished
    CampaignArmiesMerge
    CampaignBuildingDamaged
    CampaignSettlementAttacked
    CampaignSlotAttacked
    CharacterAttacksAlly
    CharacterBlockedPort
    CharacterBrokePortBlocke
    CharacterBuildsSpyNetwork
    CharacterCandidateBecomesMinister
    CharacterCanLiberate
    CharacterCompletedBattle
    CharacterCreated
    CharacterCriticallyFailsAssassination
    CharacterDamagedByDisaster
    CharacterDisembarksNavy
    CharacterEmbarksNavy
    CharacterEntersAttritionalArea
    CharacterEntersGarrison
    CharacterFactionCompletesResearch
    CharacterFactionSpyAttemptSuccessful
    CharacterFactionSuffersSuccessfulSpyAttempt
    CharacterInfoPanelOpened
    CharacterLootedSettlement
    CharacterPromoted
    CharacterSelected
    CharacterTurnEnd
    CharacterTurnStart
    ComponentLClickUp
    DuelDemanded
    DuelFought
    DummyEvent
    EspionageAgentApprehended
    evaluate_mission
    EventMessageOpenedBattle
    EventMessageOpenedCampaign
    FactionGovernmentTypeChanged
    FactionRoundStart
    FactionTurnEnd
    FactionTurnStart
    FortSelected
    GarrisonResidenceCaptured
    GovernorshipTaxRateChanged
    HarassmentAttemptSuccess
    HistoricalCharacters
    HistoricalEvents
    historical_events
    HudRefresh
    IncomingMessage
    LandTradeRouteRaided
    LoadingGame
    LocationEntered
    LocationUnveiled
    MissionCancelled
    MissionCheckAssassination
    MissionCheckBlockePort
    MissionCheckBuild
    MissionCheckCaptureCity
    MissionCheckDuel
    MissionCheckEngageCharacter
    MissionCheckEngageFaction
    MissionCheckGainMilitaryAccess
    MissionCheckMakeAlliance
    MissionCheckMakeTradeAgreement
    MissionCheckRecruit
    MissionCheckResearch
    MissionCheckSpyOnCity
    MissionEvaluateAssassination
    MissionEvaluateBlockadePort
    MissionEvaluateBuild
    MissionEvaluateCaptureCity
    MissionEvaluateDuel
    MissionEvaluateEngageCharacter
    MissionEvaluateEngageFaction
    MissionEvaluateGainMilitaryAccess
    MissionEvaluateMakeAlliance
    MissionEvaluateMakeTradeAgreement
    MissionEvaluateRecruit
    MissionEvaluateResearch
    MissionEvaluateSpyOnCity
    MissionFailed
    MissionIssued
    MissionNearingExpiry
    MissionSucceeded
    ModelCreated
    MovementPointsExhausted
    MultiTurnMove
    NewCampaignStarted
    NewSession
    PanelviceRequestedBattle
    PanelviceRequestedCampaign
    PanelClosedBattle
    PanelClosedCampaign
    PanelOpenedBattle
    PanelOpenedCampaign
    PendingBankruptcy
    PreBattle
    RecruitmentItemIssuedByPlayer
    RegionIssuesDemands
    RegionRebels
    RegionRiots
    RegionStrikes
    RegionTurnEnd
    RegionTurnStart
    ResearchCompleted
    SabotageAttemptSuccess
    SavingGame
    SeaTradeRouteRaided
    SettlementOccupied
    SettlementSelected
    SiegeLifted
    SlotOccupied
    SlotOpens
    SlotRoundStart
    SlotSelected
    SlotTurnStart
    SpyingAttemptSuccess
    SufferAssassinationAttempt
    SufferSpyingAttempt
    TechnologyInfoPanelOpenedCampaign
    TestEvent
    TimeTrigger
    Tooltipvice
    TradeLinkEstablished
    TradeRouteEstablished
    UICreated
    UIDestroyed
    UngarrisonedFort
    UnitCompletedBattle
    UnitCreated
    UnitSelectedCampaign
    UnitTrained
    UnitTurnEnd
    VictoryConditionFailed
    VictoryConditionMet
    WorldCreated


    Last edited by T.C.; June 15, 2013 at 05:40 PM.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  3. #3

    Default Re: Script-o-Rama 2

    Section II: Script Writing Tutorials

    This section explains how to write your own script and will contain more advanced stuff as it is fleshed out.

    II.1 How to use events.
    Click to view content: 
    To tie some code into an event you need to add a function onto the end of the event table needed (remember all events are tables) as follows:
    Code:
    events.EventName[#events.EventName+1] = function(context)
        code
    end
    So the following code adds some cash to a faction at the start of it's turn.
    Code:
    events.FactionTurnStart[#events.FactionTurnStart+1] = function(context)
        effect.adjust_treasury(100000, context)
    end
    This method of event hooking saves filling functions such as OnFactionTurnStart() up with your own code (thus possibly confusing you) and is more reliable for people not too familiar with scripting.
    Just remember not to place the code chunk inside another function. Code that relies on a region starting it's turn will never fire off if placed inside the OnFactionTurnStart function, as the faction and the region both start their turns at different times.


    II.2 How to create custom missions.
    Click to view content: 
    In-depth tutorial here


    II.3 How to write logs.
    Click to view content: 
    Getting the game to write logs is by far the easiest way of narrowing down bugs and telling you that certain things are working in a script. The following code chunks are functions for (i) Creating a log and (ii) Writing to the log. To understand some of the operators used, I would advise you to look at the basics section (I.1) which explains them in detail.

    Spoiler Alert, click show to read: 
    Code:
    function TCS_Create_Log ()
        local DateAndTime = os.date()
        local TCSLog = io.open("data/Logs/log.txt","w")
        TCSLog:write("[Log Created] "..DateAndTime.."\n\n")
        TCSLog:close()
    end
    Code:
    function TCS_Log_Update(update_arg)
        local DateAndTime1 = os.date("%H:%M.%S")
        local TCSLogU = io.open("data/Logs/log.txt","a")
        TCSLogU:write("\n["..DateAndTime1.."]\t\t"..tostring(update_arg)) 
        TCSLogU:close()
    end


    These functions may not make sense to anyone unfamiliar with Lua, so I've included some with comments below.

    Spoiler Alert, click show to read: 
    Code:
    --create a function that takes no arguments
    function TCS_Create_Log ()
        --sets a variable to the time and date
        local DateAndTime = os.date()
        --opens the text file in the directory supplied. Set to write mode ("w"), so if the text file 
        --exists it will be overwritten, if it doesn't it will be created.
        local TCSLog = io.open("data/Logs/log.txt","w")
        --write a header tith the date to the log, so you know when it's been updated.
        TCSLog:write("[Log Created] "..DateAndTime.."\n\n")
        --Close the log
        TCSLog:close()
    end
    Code:
    --create a function that takes only one argument
    function TCS_Log_Update(update_arg)
        --set the date in HMS format to the variable
        local DateAndTime1 = os.date("%H:%M.%S")
        --open the log in the supplied path. Opened in append mode ("a") which will append to
        --the file rather than overwrite it
        local TCSLogU = io.open("data/Logs/log.txt","a")
        --write the date in HMS format before each log entry
         TCSLogU:write("\n["..DateAndTime1.."]\t\t"..tostring(update_arg)) 
        --close the log
        TCSLogU:close()
    end


    Usage of the functions:
    The functions must both be defined, so I'd advise you to do that at the top of your script. Remember that scripts are read logically (mostly) so you must define the function before attempting to call it. I would then advise that you call the function to create the log only once, as it overwrites any logs that already exist. So it is done as follows:
    Code:
    TCS_Create_Log ()
    Then you can use the log updater as often as you wish. Here is an example of basic usage:
    Code:
    TCS_Log_Update("hello World!")
    Which will output the following to the log file:
    Code:
    [12:46.13]        Hello World!
    If you supply an argument to the function that doesn't exist, it will most likely catch it out as it uses the tostring() converter.
    So this code:
    Code:
    TCS_Log_Update(hello World!)
    Outputs this:
    Code:
    [12:46.13]        nil
    Keep in mind that I've left out the error catching I would use on my own logging functions so as to keep the code simple - it may not handle all incorrect syntax values the same.

    Another excellent use of this is to log the output of functions. The following code logs the output of a CampaignUI function.
    Code:
    local Logvariable = CampaignUI.RetrieveDiplomaticStanceString("france", "britain")
    TCS_Log_Update(Logvariable)
    And the output itself:
    Code:
    [12:46.13]        at war


    II.4 How to edit UI components (basic).
    Click to view content: 
    To edit UI components the most effective way is to get a decompiled file, fix it, edit it and recompile it. This obviously isn't an option for most people, so what follows is a basic example of how to do it via scripting.lua and episodicscripting.

    First things first, you need to know the name of your component to edit. There's no simple way to do this, you just have to crawl through game files and find somewhere else where it is referenced globally (i.e. not locally). When you know the name of your component to edit, you need to add an entry to the table m_features table of episodicscripting. This is done by adding some code as follows to the end of the table:
    Code:
        ["disable_end_turn"] = {
            ["Enable"] = function()
                out.ting("End turn disabled")
                UIComponent(m_root:Find("button_end_turn")):SetVisible(false)
                UIComponent(m_root:Find("button_end_turn")):SetDisabled(true)
            end,
            ["Disable"] = function()
                out.ting("End turn re-enabled")
                UIComponent(m_root:Find("button_end_turn")):SetVisible(true)
                UIComponent(m_root:Find("button_end_turn")):SetDisabled(false)
            end
            },
    And here it is with some comments to make it easier to understand:

    Code:
        --set the feature name
        ["disable_end_turn"] = {
            --define the enable function
            ["Enable"] = function()
                --code that will be executed when the enable function is called
                out.ting("End turn disabled")
                UIComponent(m_root:Find("button_end_turn")):SetVisible(false)
                UIComponent(m_root:Find("button_end_turn")):SetDisabled(true)
            end,
            --define the disable function
            ["Disable"] = function()
                --code that will be executed when the disable func is called
                out.ting("End turn re-enabled")
                UIComponent(m_root:Find("button_end_turn")):SetVisible(true)
                UIComponent(m_root:Find("button_end_turn")):SetDisabled(false)
            end
            },
    To actually edit the UI components you need to use the UIComponent() function. This is documented as follows:
    Code:
    UIComponent(m_root:Find(<<Name of component>>)):<<function to call on component>>
    And an example here:
    Code:
    UIComponent(m_root:Find("button_end_turn")):SetDisabled(false)
    I've only seen SetDisabled or SetVisible used in episodicscripting but here are other commands used in luacs:
    • SetStateText(<<string>>)
    • SetState(<<string>>) (Only useable if you can compare to UI xmls)
    • SetTooltipText(<<string>>)


    There are lots more, but those are the most relevant.

    So now you've added your feature to the table, you'll need to call it. That's pretty simple to do - from scripting.lua (or anywhere else where the episodicscripting module is loaded) just use the following code:
    Code:
    scripting.EnableFeature(<<feature name>>)
    scripting.DisableFeature(<<Feature name>>)
    EnableFeature will execute any code defined under the "Enable" table and Disable Feature will do the same for anything under the "Disable" table.

    Examples of useage:
    Code:
    scripting.EnableFeature("Hide_prestige_tab") 
    scripting.DisableFeature("hide_campaign_hud")


    Section III: Miscellaneous

    Everything that doesn't fit somewhere else goes here.

    III.1 Use Cases

    Click to view content: 
    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


    III.2 Useful Links

    Click to view content: 


    Last edited by T.C.; June 15, 2013 at 05:38 PM.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  4. #4

    Default Re: Script-o-Rama 2

    And reserved again
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  5. #5
    Steph's Avatar Maréchal de France
    Patrician Artifex

    Join Date
    Apr 2010
    Location
    Pont de l'Arn, France
    Posts
    9,174

    Default Re: Script-o-Rama 2

    Here are some ideas I have, do you think there is a chance to make it work? Maybe with WALI? And would you be willing to help make them work?

    1) On the campaign them, you can recruit a "regiment" unit. Armies on the campaign map contains only regiment. But when you start a battle the "regiment" is replaced by several "companies", just before starting the battle. Exemple: on the campaign map, a French Line Infantry regiment will be replaced by 1 grenadier, 1 voltigeurs and 4 fusiliers in battle.

    2) The name of the units in campaign (regiment name) doesn't work as well as I'd like. It's not possible to make it take properly the allies (i.e. if you recruit a French unit as Britain, the name could be 47th regiment of foot instead of 8čme regiment d'infanterie de ligne). My idea would be to provide a correct list of names for each type of units, in a Scripting file, and when a unit is recruited, change the name to one from this list.

    For exemple, how does "SetMyUnitName" works?

    3) The portraits for generals added to the recruitment pool is random. Do you think we could use InitialiseCharacterDetails or AvailableCommandersForRecruitment ?
    Last edited by Steph; June 16, 2013 at 03:07 AM.

  6. #6

    Default Re: Script-o-Rama 2

    Quote Originally Posted by Steph View Post
    Here are some ideas I have, do you think there is a chance to make it work? Maybe with WALI? And would you be willing to help make them work?

    1) On the campaign them, you can recruit a "regiment" unit. Armies on the campaign map contains only regiment. But when you start a battle the "regiment" is replaced by several "companies", just before starting the battle. Exemple: on the campaign map, a French Line Infantry regiment will be replaced by 1 grenadier, 1 voltigeurs and 4 fusiliers in battle.

    2) The name of the units in campaign (regiment name) doesn't work as well as I'd like. It's not possible to make it take properly the allies (i.e. if you recruit a French unit as Britain, the name could be 47th regiment of foot instead of 8čme regiment d'infanterie de ligne). My idea would be to provide a correct list of names for each type of units, in a Scripting file, and when a unit is recruited, change the name to one from this list.

    For exemple, how does "SetMyUnitName" works?

    3) The portraits for generals added to the recruitment pool is random. Do you think we could use InitialiseCharacterDetails or AvailableCommandersForRecruitment ?
    Idea 1 isn't really possible, but you could recruit a regiment and have the individual units spawn on the campaign map (where the recruitment was made). But we'd need a lot more memory mapping done for this to be possible.

    2, same as 1. More research needed, but theoretically possible.

    3, these are only getters. Not setters. I started documenting them last night, I'm going to post it here now. Take a look when it's up.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  7. #7

    Default Re: Script-o-Rama 2

    Updated with InitialiseUnitDetails and InitialiseCharacterDetails. More to follow
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  8. #8
    Steph's Avatar Maréchal de France
    Patrician Artifex

    Join Date
    Apr 2010
    Location
    Pont de l'Arn, France
    Posts
    9,174

    Default Re: Script-o-Rama 2

    For 1), since we have a GrandUnit, we could spawn easily the new units. The real difficulty is to "replace" the regiment with the new unit. However, this doesn't prevent the player or AI from moving the companies separately.
    3)If Wali allows changing some info in memory, the getters can give the name of the units, and then Wali can be used to change the portrait no?
    2)Same, if we can get the info with the getters, then we could replace with Wali.

    Argh, I need more free time to play with that!

  9. #9

    Default Re: Script-o-Rama 2

    Quote Originally Posted by Steph View Post
    For 1), since we have a GrandUnit, we could spawn easily the new units. The real difficulty is to "replace" the regiment with the new unit. However, this doesn't prevent the player or AI from moving the companies separately.
    3)If Wali allows changing some info in memory, the getters can give the name of the units, and then Wali can be used to change the portrait no?
    2)Same, if we can get the info with the getters, then we could replace with Wali.

    Argh, I need more free time to play with that!
    That's true, it would take more research alright.
    About the getters: they just provide raw information, and very little traceability. The information built comes from multiple different areas in memory (a fact I know, from research done last year). The only information useable for tracing is the addresses provided. See InitialiseUnitDetails and InitialiseCharacterDetails sample output above for examples.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  10. #10

    Default Re: Script-o-Rama 2

    Fabulous work TC +Rep!
    Ordoprinceps
    Semper Ferox

  11. #11
    Lord Davn's Avatar Senator
    Join Date
    Jul 2011
    Location
    Milwaukee, WI
    Posts
    1,070

    Default Re: Script-o-Rama 2

    In the original scripting files for the SP Campaign the AI is scripted to have the Ottomans & Austria go to war with one another. I can not find the line in the script file (mp_eur_napoleon folder) that triggers this. I've tried to write a script line for peace between the two factions put they just go to war on the next turn. Is there another to disable this event?

  12. #12
    Steph's Avatar Maréchal de France
    Patrician Artifex

    Join Date
    Apr 2010
    Location
    Pont de l'Arn, France
    Posts
    9,174

    Default Re: Script-o-Rama 2 (UPDATED 16/06/13)

    are you sure they are scripted? And not just very likely to happen because of the AI?

  13. #13

    Default Re: Script-o-Rama 2 (UPDATED 16/06/13)

    As said in a PM conversation, this is not scripted - just a certainty based on AI relationships. In fact the AI in the grand campaign has no scripting.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  14. #14
    Lord Davn's Avatar Senator
    Join Date
    Jul 2011
    Location
    Milwaukee, WI
    Posts
    1,070

    Default Re: Script-o-Rama 2 (UPDATED 16/06/13)

    Quote Originally Posted by Steph View Post
    are you sure they are scripted? And not just very likely to happen because of the AI?
    T.C. cleared this up with a quick reply.
    Quote Originally Posted by T.C.
    You can't find the line because the event isn't scripted - the startpos diplomacy relations are set so bad that they will always go to war. Show me the script line you have used and I'll see where you are going wrong.


    I redid the diplomacy settings to make the Ottomans neutral with Austria (& Russia) as historically they were to weak to pick a fight and it distracts the Austrians from their main enemy the French army at the start of the campaign game.
    Here is the scripting line that T.C. suggested & works to end the Ottomans insistence to go to war with Austria. The only draw back that T.C. noted was they never will be able to go to war with each other during the campaign
    Last edited by Lord Davn; September 01, 2013 at 02:54 PM.

  15. #15
    Inevitability won
    Patrician Citizen

    Join Date
    Mar 2010
    Posts
    9,594

    Default Re: Script-o-Rama 2 (UPDATED 16/06/13)

    Why don't you wait until a certain number of turns later in the campaign then re-enable the wars.

    Giving them that time will either mean their relations have improved which will mean they won't want to go to war, or they will still dislike each other in which case war is inevitable anyway.

  16. #16
    Lord Davn's Avatar Senator
    Join Date
    Jul 2011
    Location
    Milwaukee, WI
    Posts
    1,070

    Default Re: Script-o-Rama 2 (UPDATED 16/06/13)

    Quote Originally Posted by .Mitch. View Post
    Why don't you wait until a certain number of turns later in the campaign then re-enable the wars. Giving them that time will either mean their relations have improved which will mean they won't want to go to war, or they will still dislike each other in which case war is inevitable anyway.
    That's a very good idea, I'll look at putting that in the scripting file with the next update we do for our NTW3 SP Campaign v3.4 mod. That will give those that play the Ottoman's a chance to build up their army. They're also still free to take on the Russians if they want to.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •