Results 1 to 30 of 116

Thread: An Intermediate Guide to Scripting

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: An Intermediate Guide to Scripting

    Do you have a loop so that the script is still running the next turn?
    Maybe that's my problem. I was under the assumption that if a script was launched, that it will persist throughout the entire game session, including all the monitors. Is that right, or do I have to have some sort of loop to keep the script persisting through the turns?

    All of the action that I want to happen above is inside the monitor, which I thought will persist though turn 2, even though loaded at turn 1 (assuming the game wasn't reloaded).
    Last edited by SigniferOne; 03-11-2006 at 02:56.

  2. #2

    Default Re: An Intermediate Guide to Scripting

    Have a look at the first script in the first post, there's your basic background script with a while loop. You need a while loop at the bottom otherwise the script will terminate immediately.
    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

  3. #3

    Default Re: An Intermediate Guide to Scripting

    When script execution reaches end_script command you can guess what happens next :)

  4. #4

    Default Re: An Intermediate Guide to Scripting

    I think I figured out what was going wrong:

    inside that event monitor I have two commands:

    Code:
    console_command add_money 10000
    campaign_wait 2
    console_command kill_character "Gaius Fabricius"
    campaign_wait 2
    (the campaign waits are apparently necessary for all console_commands).

    Ok so here's what happens: apparently, under some conditions, the kill_character command does-not-work, and the script processing engine seems to stop processing. What's been happening in my script, and why I was prompted to post in this thread, was that I've been developing a background script for the Paeninsula Italica mod; I tried inserting just one command that had to be in my script -- kill_character -- and it would not work (hence my posts). I started this script every time I started a new campaign in our beta campaign map, so obviously we have a lot of things unbalanced yet, and a lot of provinces (over 50) rebel on the next turn. Also, the Adoption thing springs into action, since there are like 3 generals for the entire faction.

    SO -- to make a long story short -- when I start the campaign and run my script, after pressing next turn, all this massive avalanche of events starts to happen on the next turn, and the kill_character event does not work. It is in the monitor correctly, and the monitor is triggered correctly, but the command simply doesn't work! How do I know the monitor is triggered correctly? Because I placed the give money command before it, which never fails to work. And what's even more, I placed a second give money command after it, e.g.

    Code:
    console_command add_money 10000
    campaign_wait 2
    console_command kill_character "Gaius Fabricius"
    campaign_wait 2
    console_command add_money 10000
    campaign_wait 2
    And the execution never reaches the second money command, and no money is added after the first. This is a very weird problem. Here's what's even weirder: sometimes, if I keep pressing Next Turn, the event_monitor is still apparently running in the background, sometimes will make the kill_character command work. So sometimes, a few turns in, the character does get killed (although the money command works always, at least the first one).

    It seems that the script engine somehow gets "stuck" on the kill_character command, and simply does not proceed executing any further. I thought that maybe it's from all the events happening so fast, and tried to somehow pause the game, or at least pause all the events and UI things happening, until my script monitor runs and finishes its stuff. Thus, I tried everything imaginable, e.g.:

    Code:
    	monitor_event FactionTurnStart FactionIsLocal
    		declare_show_me
    		hide_ui
    		suspend_unscripted_advice true
    		disable_entire_ui
    
    		console_command add_money 10000
    		campaign_wait 5
    		console_command kill_character "Gaius Fabricius"
    		campaign_wait 5
    		console_command add_money 10000
    		campaign_wait 5
    
    		enable_entire_ui
    		suspend_unscripted_advice false
    		show_ui
    	end_monitor
    all the things that I guessed could suspend the proper flow of the game until my poor script has finished. None of these things work. One of the funny things is, I just added the "hide_ui" thing, to try and hide the events until my script finishes, and -- the UI gets hidden, the "adoption" event pops up anyway (due to the conditions in my campaign), and when I dismiss it, the UI continues to remain hidden. The script simply does not proceed further, beyond the kill_character command, the UI remains hidden even though the script says to unhide it. It just gets stuck. And I know that the kill_character command works always when in direct script mode (i.e. without the monitors), and it sometimes works even in the monitors, seemingly when there aren't that many events popping up. So that's what's been going on with my script :-) Anyone else have something similar?
    Last edited by SigniferOne; 03-12-2006 at 07:04.

  5. #5

    Default Re: An Intermediate Guide to Scripting

    Okay guys, in order to narrow down the source of the problem, I have considerably cleaned up the campaign situation, gave the faction enough generals so that adoptions would not pop up, removed almost all the provinces owned so that there are would be no rebellions, etc. Now, practically no events happen on each turn, and yet the problem with kill_character still persists!

    I don't want to clutter up ER's thread with this one problem, so I've started a new thread, where I explain the situation in less clumsy terms, the above complications have been removed as I just said, and I also posted screenshots of what goes on.

    The thread is here: https://forums.totalwar.org/vb/showthread.php?t=62364
    Last edited by SigniferOne; 03-12-2006 at 08:41.

  6. #6

    Default Re: An Intermediate Guide to Scripting

    A few more questions: the only way to browse if a character has one of a list of traits is by having a monitor event for each trait, right? i.e. there's no way to do something like right:

    if Trait X = 1
    do A
    if Trait Y = 1
    do B

    Also, is there a limit for how many "and" conditions can exist for event_monitors? This sort of information seems not to be included in the Hardcoded Limits thread.
    Last edited by SigniferOne; 03-12-2006 at 21:44.

  7. #7

    Default Re: An Intermediate Guide to Scripting

    I think that's because no one has ever hit it. From my understanding of CA it seems unlikely that they would have imposed a limit because they never expected people to be using big scripts. But equally there may be an extent by which a big monitor may not work right.

    There's no easy way to do the trait thing - however if you want to use that in many different monitors then you may want to have a separate monitor to use the existence to set a counter. You can then use an if I_CompareCounter line within your monitors.
    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

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