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
    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



  2. #2
    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

    There are several mistakes in the script. The correct syntax will depend on your idea about the events:
    - Do you want the spawning armies to appear in a specific date or only from a given year (in a randomly chosen date)?
    - Do you want the armies to spawn only once in game?
    - Do you want the armies to spawn at the same time?

    Just to test the syntax, you can prepare a short script that would allow one army to spawn in one early date (let's say turn number 2).

    Several advices:
    - You must declare all the counters used along the script: declare_counter spawn_armyA, etc.
    - If the army must appear when the counter is zero, you must use the command: I_CompareCounter spawn_armyA = 0 (see the docudemon files).
    Put it as part of the monitor_event
    - Once the army appears, you must change the counter, either setting the value or increasing one unit: set_counter spawn_armyA 1

    In any case, if the army is going to appear only once in a given date, forget the counter and set just the turn number.
    If the armies appear in different turns (with a given order), you can use only one counter, and put in the event the different values (for army A, I_CompareCounter spawn_armyA = 0; for army B, I_CompareCounter spawn_armyA = 1; etc).

    Good luck with the script.

  3. #3

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

    - Do you want the spawning armies to appear in a specific date or only from a given year (in a randomly chosen date)?
    - Do you want the armies to spawn only once in game?
    - Do you want the armies to spawn at the same time?
    To these questions , my idea is to spawn the army only once at a specific date, for instance the first Greek army (Phyrrus) on summer 275 BC. I've restested my script (without editing from the frist spawn (in 275) to the second (in 246) and it works both times. The only this is if I save the game and reload. The second spawn (hamilcar in Sicily) keeps respawning every time I load the game and so the third one (Gaul) in 236 ..(not quite sure the date , but something like that.. )

    Just to test the syntax, you can prepare a short script that would allow one army to spawn in one early date (let's say turn number 2).

    Several advices:
    - You must declare all the counters used along the script: declare_counter spawn_armyA, etc.
    - If the army must appear when the counter is zero, you must use the command: I_CompareCounter spawn_armyA = 0 (see the docudemon files).
    Put it as part of the monitor_event
    - Once the army appears, you must change the counter, either setting the value or increasing one unit: set_counter spawn_armyA 1
    Actually I tried to read the docudemon file .. but coun't make any sense of it. Might be because of my poor command of English or my zero knowledge about codes / pc scripts etc..

    In any case, if the army is going to appear only once in a given date, forget the counter and set just the turn number.
    If the armies appear in different turns (with a given order), you can use only one counter, and put in the event the different values (for army A, I_CompareCounter spawn_armyA = 0; for army B, I_CompareCounter spawn_armyA = 1; etc).
    Guess this is what I'm gonna do. Thanks for the advice and I'm gonna see how it works. Just a quick question, will the script take any effect in middel of campaign ? Or will have to restart a new one ?
    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.

  4. #4
    Honorary Argentinian Senior Member Gyroball Champion, Karts Champion Caius's Avatar
    Join Date
    Aug 2006
    Location
    I live in my home, don't you?
    Posts
    8,114

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

    ok.

    I explain what im trying to do.I am making a autosave script for RTW 1.5.Yes, there is a feature of autosave, but it is damaged or something that makes a CTD when you click the end turn.
    So, I believe if I create a autosave script, this script will fix the problem.
    Now, How can I create a script of end turn?




    Names, secret names
    But never in my favour
    But when all is said and done
    It's you I love

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

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

    Do you see the problem you mention with Autosave in an un-modded game? Autosave (or a manual save) will crash if you've made a mistake character names. I suspect this or some other mod-related change is your real problem.
    The truth is the most valuable thing we have. Let us economize it. - Mark Twain



  6. #6
    Honorary Argentinian Senior Member Gyroball Champion, Karts Champion Caius's Avatar
    Join Date
    Aug 2006
    Location
    I live in my home, don't you?
    Posts
    8,114

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

    Quote Originally Posted by Atilius
    Do you see the problem you mention with Autosave in an un-modded game? Autosave (or a manual save) will crash if you've made a mistake character names. I suspect this or some other mod-related change is your real problem.
    It is the imperial campaign un-modded.
    I'm not the only who haves the same problem




    Names, secret names
    But never in my favour
    But when all is said and done
    It's you I love

  7. #7

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

    tried using the example script for mo_money but that particular section of the txt seems to be disabled in patch 1.5. Tried using the advice thread for the settlements list again no joy.

    I'm trying to get force_diplomacy to work so I can play around with that in the early game if anyone has any help they could give I'd love to click their 'show me how' button.


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