Results 1 to 30 of 102

Thread: A Beginner's Guide to Scripting & Scripting "How To"s

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    is not a senior Member Meneldil's Avatar
    Join Date
    Aug 2004
    Location
    France
    Posts
    3,074

    Default Re : A Beginner's Guide to Scripting & Scripting "How To"s

    Well, I don't think so actually.
    With BI, the shortcut advisor apparently doesn't work (there are commas that prevent the script from working) : if you click on the advice button, nothing will happen.
    I deleted the commas, both before the trigger and before the advisor thread, and I did not add any script. I launched the campaign, and clicked on '?' in the shortcut panel, and the game stopped aswell.

    Edit : Oddly, the script will work with another advisor help request command.
    Last edited by Meneldil; 12-06-2005 at 22:35.

  2. #2

    Default Re: A Beginner's Guide to Scripting & Scripting "How To"s

    I have a little (though annoying problem) regaring this script. Maybe I did it wrong way but here it goes.

    In my Imperator mod, I added the spawn army script to make Phyrrus army reappeared in summer 275 BC. I edited base on the 4TPY script. Everything goes fine, the years came and the army 'arrived' and I had another great but difficult battle with the Greeks when I thought that Phyrrus has finally been banished from Italy.

    The problem came after the event has passed. Everytime I restarted the game, after save and reloading, everytime I started the 4TPY script the army reappears , even when the Greek Cities has been eliminated. Didn't cause CTD or anything, and the game can goes on with no problem at all (except the battle with Phyrrus with his elephant army again... )

    Do note however, this only happened 'after' restarting the game If reload a save game from already on going game this 'bug' wont appear. What I always did is reload again and the spawn thing didn't appear anymore.

    I'm at lost....
    Say: O unbelievers, I serve not what you serve, nor do you serve what I serve, nor shall I serve what you are serving, nor shall you be serving what I serve.
    To you your religion, and to me my religion.

  3. #3

    Default Re: A Beginner's Guide to Scripting & Scripting "How To"s

    Are you using a background script or an event script?

    Post the bits of your scripting files relevant to this event and we'll have a look.
    Epistolary Richard's modding Rules of Cool
    Cool modders make their mods with the :mod command line switch
    If they don't, then Cool mod-users use the Mod Enabler (JSGME)
    Cool modders use show_err
    Cool modders use the tutorials database Cool modders check out the Welcome to the Modding Forums! thread Cool modders keep backups Cool modders help each other out

  4. #4

    Default Re: A Beginner's Guide to Scripting & Scripting "How To"s

    script

    while I_TurnNumber < 1840
    select_ui_element advisor_dismiss_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up

    suspend_unscripted_advice true

    ;;;;;;;; spawn_army ;;;;;;
    declare_counter spawn_army

    if I_TurnNumber = 0
    set_counter spawn_armyA 0
    set_counter spawn_armyB 0
    set_counter spawn_armyC 0
    set_counter spawn_armyD 0
    end_if


    ;;;;;;;; spawn_army ;;;;;;
    monitor_event FactionTurnStart FactionType greek_cities
    and I_TurnNumber > 21

    if spawn_armyA = 0

    spawn_army
    faction greek_cities
    character Pyrrhus of Epirus, named character, command 3, influence 1, management 1, subterfuge 0, age 38, , x 112, y 67
    unit greek general's guard cavalry exp 1 armour 0 weapon_lvl 0
    unit epirote pikemen exp 2 armour 0 weapon_lvl 0
    unit epirote pikemen exp 1 armour 0 weapon_lvl 0
    unit greek medium cavalry exp 0 armour 0 weapon_lvl 0
    unit greek hoplite exp 2 armour 0 weapon_lvl 0
    unit greek hoplite exp 1 armour 0 weapon_lvl 0
    unit greek hoplite exp 2 armour 0 weapon_lvl 0
    unit greek hoplite exp 1 armour 0 weapon_lvl 0
    unit greek hoplite militia exp 0 armour 1 weapon_lvl 0
    unit greek hoplite militia exp 0 armour 1 weapon_lvl 0
    unit aor greece thessalian cavalry exp 1 armour 0 weapon_lvl 0
    unit merc rhodian slingers exp 1 armour 0 weapon_lvl 0
    unit merc cretan archers exp 1 armour 0 weapon_lvl 0
    unit merc elephants exp 1 armour 0 weapon_lvl 0
    unit greek hoplite militia exp 0 armour 1 weapon_lvl 0
    unit merc rhodian slingers exp 1 armour 0 weapon_lvl 0
    unit merc cretan archers exp 1 armour 0 weapon_lvl 0
    set_counter spawn_armyA 1
    end_if

    terminate_monitor
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and I_TurnNumber > 138

    if spawn_armyB = 0

    spawn_army
    faction carthage
    character Himilcar Barca, general, command 5, influence 5, management 0, subterfuge 3, age 40, x 96, y 47
    unit carthaginian general's cavalry exp 1 armour 0 weapon_lvl 0
    unit carthaginian sacred band infantry exp 3 armour 1 weapon_lvl 1
    unit carthaginian sacred band infantry exp 3 armour 1 weapon_lvl 1
    unit libyan spearmen exp 1 armour 0 weapon_lvl 0
    unit libyan spearmen exp 1 armour 0 weapon_lvl 0
    unit libyan spearmen exp 2 armour 1 weapon_lvl 1
    unit libyan spearmen exp 1 armour 0 weapon_lvl 0
    unit aor spain infantry exp 2 armour 1 weapon_lvl 1
    unit aor spain infantry exp 1 armour 0 weapon_lvl 0
    unit aor spain infantry exp 1 armour 0 weapon_lvl 0
    unit aor spain infantry exp 1 armour 0 weapon_lvl 0
    unit aor spain infantry exp 1 armour 0 weapon_lvl 0
    unit merc balearic slingers exp 2 armour 0 weapon_lvl 0
    unit merc balearic slingers exp 2 armour 0 weapon_lvl 0
    unit aor spain cavalry exp 2 armour 0 weapon_lvl 0
    unit aor spain cavalry exp 2 armour 0 weapon_lvl 0
    unit merc numidian cavalry exp 2 armour 0 weapon_lvl 0
    unit merc numidian cavalry exp 2 armour 0 weapon_lvl 0
    unit carthaginian elephant forest exp 0 armour 0 weapon_lvl 0
    unit carthaginian elephant forest exp 0 armour 0 weapon_lvl 0
    set_counter spawn_armyB 1
    end_if

    terminate_monitor
    end_monitor

    monitor_event FactionTurnStart FactionType gauls
    and I_TurnNumber > 177

    if spawn_armyC = 0

    spawn_army
    faction gauls
    character Dumnorix of Bibrax, general, command 5, influence 0, management 0, subterfuge 0, age 20, , x 89, y 91
    unit barb chieftain cavalry gaul exp 1 armour 0 weapon_lvl 0
    unit barb infantry gaul exp 0 armour 0 weapon_lvl 0
    unit barb infantry gaul exp 1 armour 0 weapon_lvl 0
    unit barb infantry gaul exp 0 armour 0 weapon_lvl 0
    unit barb infantry gaul exp 1 armour 0 weapon_lvl 0
    unit barb infantry gaul exp 0 armour 0 weapon_lvl 0
    unit barb infantry gaul exp 1 armour 0 weapon_lvl 0
    unit barb infantry gaul exp 0 armour 0 weapon_lvl 0
    unit barb infantry gaul exp 1 armour 0 weapon_lvl 0
    unit barb peltast gaul exp 1 armour 0 weapon_lvl 0
    unit barb peltast gaul exp 1 armour 0 weapon_lvl 0
    unit gaul gothic hev inf exp 3 armour 0 weapon_lvl 0
    unit gaul gothic hev inf exp 3 armour 0 weapon_lvl 0
    unit gaul gothic hev inf exp 3 armour 0 weapon_lvl 0
    unit barb cavalry gaul exp 3 armour 0 weapon_lvl 0
    unit barb cavalry gaul exp 3 armour 0 weapon_lvl 0
    unit barb cavalry gaul exp 3 armour 0 weapon_lvl 0
    set_counter spawn_armyC 1
    end_if

    terminate_monitor
    end_monitor

    monitor_event FactionTurnStart FactionType carthage
    and I_TurnNumber > 249

    if spawn_armyD = 0

    spawn_army
    faction carthage
    character Hannibal Barca, general, command 6, influence 5, management 0, subterfuge 3, age 40, x 89, y 91
    unit carthaginian general's cavalry exp 1 armour 0 weapon_lvl 0
    unit carthaginian sacred band infantry exp 3 armour 1 weapon_lvl 1
    unit carthaginian sacred band infantry exp 3 armour 1 weapon_lvl 1
    unit libyan spearmen exp 1 armour 0 weapon_lvl 0
    unit libyan spearmen exp 1 armour 0 weapon_lvl 0
    unit libyan spearmen exp 2 armour 1 weapon_lvl 1
    unit libyan spearmen exp 1 armour 0 weapon_lvl 0
    unit aor spain infantry exp 2 armour 1 weapon_lvl 1
    unit aor spain infantry exp 1 armour 1 weapon_lvl 0
    unit aor spain infantry exp 1 armour 1 weapon_lvl 0
    unit aor spain infantry exp 1 armour 1 weapon_lvl 0
    unit aor spain infantry exp 1 armour 1 weapon_lvl 0
    unit merc balearic slingers exp 2 armour 1 weapon_lvl 1
    unit merc balearic slingers exp 2 armour 1 weapon_lvl 1
    unit aor spain cavalry exp 2 armour 0 weapon_lvl 0
    unit aor spain cavalry exp 2 armour 0 weapon_lvl 0
    unit merc numidian cavalry exp 2 armour 1 weapon_lvl 1
    unit merc numidian cavalry exp 2 armour 1 weapon_lvl 1
    unit merc numidian cavalry exp 2 armour 1 weapon_lvl 1
    unit carthaginian elephant forest exp 1 armour 0 weapon_lvl 0
    set_counter spawn_armyD 1
    end_if

    terminate_monitor
    end_monitor

    ;;;;;;;;;;;;;;; 4 TPY ;;;;;;;;;;;;;;;;

    console_command date -280
    console_command season summer
    declare_counter Season_Year_Turn0_Thread
    while I_TurnNumber = 0
    monitor_conditions I_CompareCounter Season_Year_Turn0_Thread = 0
    if I_CompareCounter Season_Year_Turn0_Thread = 0
    advance_advice_thread Season_Year_Turn0_Thread
    inc_counter Season_Year_Turn0_Thread 1
    end_if
    end_monitor
    suspend_unscripted_advice true
    end_while

    console_command date -280
    console_command season summer
    declare_counter Season_Year_Turn1_Thread
    while I_TurnNumber = 1
    monitor_conditions I_CompareCounter Season_Year_Turn1_Thread = 0
    if I_CompareCounter Season_Year_Turn1_Thread = 0
    advance_advice_thread Season_Year_Turn1_Thread
    inc_counter Season_Year_Turn1_Thread 1
    end_if
    end_monitor
    suspend_unscripted_advice true
    end_while
    Back to my earlier question, I think I solved the first part Phyrrus (no respawned second time) , but the rest keeps respawning.. everytime I reload the game (restart the game). But if then I hit ESC , reload again, start the 4TPY script and it's gone.

    Note: I mod it base on the 4TPY script by Marcus Camillus (from RTR.org)
    Say: O unbelievers, I serve not what you serve, nor do you serve what I serve, nor shall I serve what you are serving, nor shall you be serving what I serve.
    To you your religion, and to me my religion.

  5. #5
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: A Beginner's Guide to Scripting & Scripting "How To"s

    Quote Originally Posted by LestaT
    Back to my earlier question, I think I solved the first part Phyrrus (no respawned second time) , but the rest keeps respawning.. everytime I reload the game (restart the game). But if then I hit ESC , reload again, start the 4TPY script and it's gone.
    This is because you cannot launch a second time a script if you don't exit the game. When you reload without restarting, the script simply doesn't launch (at least this happened to me).

  6. #6

    Default Re: A Beginner's Guide to Scripting & Scripting "How To"s

    That could be. It's just that I think the first spawn army script is correct, so they only spwan once in 275BC.

    But I'm not sure about the rest of the script. Maybe somebody can help me correct it.
    Say: O unbelievers, I serve not what you serve, nor do you serve what I serve, nor shall I serve what you are serving, nor shall you be serving what I serve.
    To you your religion, and to me my religion.

  7. #7
    Bibliophilic Member Atilius's Avatar
    Join Date
    Oct 2005
    Location
    America Medioccidentalis Superior
    Posts
    3,837

    Post Re: A Beginner's Guide to Scripting & Scripting "How To"s

    LestaT,

    I don't know much about scripting, though I'm trying to learn about it. I am a software engineer though, and I see some problems with your script based purely on programming principles.


    Code:
    ;;;;;;;; spawn_army ;;;;;;
    declare_counter spawn_army
    
    if I_TurnNumber = 0
    set_counter spawn_armyA 0
    set_counter spawn_armyB 0
    set_counter spawn_armyC 0
    set_counter spawn_armyD 0
    end_if
    You've declared a counter named spawn_army but you don't use it. You actually use spawn_armyA, spawn_armyB, spawn_armyC, and spawn_armyD, but you haven't declared them as counters.

    I'm pretty sure that the counter values are only preserved while your script is being executed, so they ought to be assigned a value before they are used. Your script only does this if I_TurnNumber = 0.

    It also doesn't look to me like you need any of your counters. I'd suggest you get rid of everything you posted in red and change

    Code:
    ;;;;;;;; spawn_army ;;;;;;
    monitor_event FactionTurnStart FactionType greek_cities
    and I_TurnNumber > 21
    to

    Code:
    ;;;;;;;; spawn_army ;;;;;;
    monitor_event FactionTurnStart FactionType greek_cities
    and I_TurnNumber = 21
    You should do likewise for your other spawns.

    Shouldn't your Gauls show up about 10 years later for Telamon in 225 BC?
    The truth is the most valuable thing we have. Let us economize it. - Mark Twain



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO