Results 1 to 7 of 7

Thread: All about scripting

  1. #1

    Default All about scripting

    I was tinkering with the scripting.lua file in campaign folder.

    I was wondering about the possibilities that can be added to the campaign:

    - Uniform change on units you already have (a possible workaround code?)
    - Allied AI armies will follow the same route as your armies
    - Strictly historical sequence of events:

    (such as the Germans' switching of sides after Napoleon's defeat at Leipzig)


    But first of all we probably need a Scripting Guide. Do you have one?

  2. #2

    Default Re: All about scripting

    Could somebody give the uses of the following codes:

    add_restricted_unit_record
    add_time_trigger
    admin1_classical_economics
    advice
    all
    allied
    allowed
    any
    are
    as
    back
    be
    been
    blockade
    blockade_port
    bug
    build
    build_building
    buildings
    by
    callbacks
    called
    camera_pan
    campaign
    campaign_won
    can
    capture
    capture_city
    changed
    changes
    check
    conditions
    context
    create
    current_advice
    currently
    dialogue_box
    directory
    disable
    documentation
    does
    economy1_poverty_control_laws
    empire
    enabling
    engaged
    event
    events
    exist
    export_advice
    export_historic_events
    file
    force_rebellion_in_region
    forge_alliance
    forum
    fought
    game
    game_interface
    generic
    give
    given
    grant_agent
    grant_experience_army
    grant_faction_handover
    grant_unit
    had
    has
    have
    historic_events
    inform
    is
    is_key_up
    its
    key
    kingdom
    list
    load_value
    local_current_advice
    make
    message
    mission
    money
    need
    new_game
    no
    of
    off
    official
    often
    on
    once
    other
    out
    panel_manager
    panelmanager
    patience
    phase
    player
    players
    port
    rebellions
    regions
    remove_restricted_building_level_record
    remove_restricted_unit_record
    report
    research
    research_technology
    run
    save_value
    scripting
    see
    settlement
    show_shroud
    states
    steal_user_input
    supported
    sure
    take
    taken
    tech
    tell
    telling
    test
    to
    trigger
    turn
    twice
    uniforms
    units
    utils
    well
    won
    you
    your

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

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

    Default Re: All about scripting

    There are a few guides in the tutorial section. Nothing more.

  4. #4

    Default Re: All about scripting

    There seems to be something wrong with this line of code: if IsYearTurn(context, 1810, 1) and CampaignUI.IsPlayersTurn() then ReplaceUnit("MoE_Art_Foot_Sweden_12_lber_1805_Sweden", "MoE_Art_Foot_Sweden_12_lber_1810_Sweden") ReplaceUnit("MoE_Art_Foot_Sweden_6_lber_1805_Sweden", "MoE_Art_Foot_Sweden_6_lber_1810_Sweden") ReplaceUnit("MoE_Art_Foot_Sweden_6_In_Howitzer_1805_Sweden", "MoE_Art_Foot_Sweden_6_In_Howitzer_1810_Sweden") ReplaceUnit("MoE_Art_Horse_Sweden_6_lber_1805_Sweden", "MoE_Art_Horse_Sweden_6_lber_1810_Sweden") ReplaceUnit("MoE_Inf_Line_Sweden_Musketeers_Varvade_1805_Sweden", "MoE_Inf_Line_Sweden_Musketeers_Varvade_1810_Sweden") ReplaceUnit("MoE_Inf_Line_Sweden_Musketeers_Indelta_1810_Sweden", "MoE_Inf_Line_Sweden_Musketeers_Indelta_1805_Sweden") ReplaceUnit("MoE_Inf_Skirm_Sweden_Jager_Varvade_1805_Sweden", "MoE_Inf_Skirm_Sweden_Jager_Varvade_1810_Sweden") ReplaceUnit("MoE_Inf_Skirm_Sweden_Jager_Indelta_1805_Sweden", "MoE_Inf_Skirm_Sweden_Jager_Indelta_1810_Sweden") ReplaceUnit("MoE_Inf_Militia_Sweden_Militia_1805_Sweden", "MoE_Inf_Militia_Sweden_Militia_1810_Sweden") end

  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: All about scripting

    it should be the other way around...

  6. #6

    Default Re: All about scripting

    Quote Originally Posted by pogi View Post
    There seems to be something wrong with this line of code: if IsYearTurn(context, 1810, 1) and CampaignUI.IsPlayersTurn() then ReplaceUnit("MoE_Art_Foot_Sweden_12_lber_1805_Sweden", "MoE_Art_Foot_Sweden_12_lber_1810_Sweden") ReplaceUnit("MoE_Art_Foot_Sweden_6_lber_1805_Sweden", "MoE_Art_Foot_Sweden_6_lber_1810_Sweden") ReplaceUnit("MoE_Art_Foot_Sweden_6_In_Howitzer_1805_Sweden", "MoE_Art_Foot_Sweden_6_In_Howitzer_1810_Sweden") ReplaceUnit("MoE_Art_Horse_Sweden_6_lber_1805_Sweden", "MoE_Art_Horse_Sweden_6_lber_1810_Sweden") ReplaceUnit("MoE_Inf_Line_Sweden_Musketeers_Varvade_1805_Sweden", "MoE_Inf_Line_Sweden_Musketeers_Varvade_1810_Sweden") ReplaceUnit("MoE_Inf_Line_Sweden_Musketeers_Indelta_1810_Sweden", "MoE_Inf_Line_Sweden_Musketeers_Indelta_1805_Sweden") ReplaceUnit("MoE_Inf_Skirm_Sweden_Jager_Varvade_1805_Sweden", "MoE_Inf_Skirm_Sweden_Jager_Varvade_1810_Sweden") ReplaceUnit("MoE_Inf_Skirm_Sweden_Jager_Indelta_1805_Sweden", "MoE_Inf_Skirm_Sweden_Jager_Indelta_1810_Sweden") ReplaceUnit("MoE_Inf_Militia_Sweden_Militia_1805_Sweden", "MoE_Inf_Militia_Sweden_Militia_1810_Sweden") end

    Hey guys, this is pretty close to something I need to do.

    Is this saying:
    If the year is 1810 season 1, and its the players turn, then Replace ("Unit1", WITH "Unit2") for like 10 different instances?

    How exactly is this working?
    Is it taking every UNIT1 the player (or A.I too?) owns and replacing it with UNIT2?
    Is there a way to narrow this down to a certain unit or army only?

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

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

    Default Re: All about scripting

    no, this is not possible.

    What it does is make the 1805 units not recruitable anymore, and then make the 1810 units recruitable instead (they were obviously not recruitable before).

    There is no way to replace an existing units with another via script. At least no way that I know about.

Posting Permissions

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