Results 1 to 30 of 116

Thread: An Intermediate Guide to Scripting

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member Member paullus's Avatar
    Join Date
    Aug 2005
    Location
    always in places where its HOT
    Posts
    11,904

    Default Re: An Intermediate Guide to Scripting

    Oh ok, I guess I misunderstood. Thanks.
    "The mere statement of fact, though it may excite our interest, is of no benefit to us, but when the knowledge of the cause is added, then the study of history becomes fruitful." -Polybios


  2. #2

    Default Re: An Intermediate Guide to Scripting

    I don't understand, I'm using Malrubius' code:

    Code:
    monitor_event CharacterTurnStart FactionType empire_west
          and Trait AgeTraitLevel1 = 1
             ; do some stuff
         
    end_monitor
    To do something to the character when a turn starts, but nothing happens. Here's the full code:

    Code:
    	console_command give_trait "Gaius Fabricius" GoodCommander 2
    	campaign_wait 2
    	console_command add_money 1000
    	campaign_wait 2
    
    	monitor_event CharacterTurnStart FactionType empire_west
    		and Trait GoodCommander = 2
    
    		; do stuff
    
    	end_monitor
    I start the campaign, press F1 and run the script, the Trait is added, I press Next Turn expecting some stuff to happen to the char based on that trait, but nothing happens... Help?

    PS: ER, would you like me to use the other thread referencing this one from now on?
    Last edited by SigniferOne; 03-10-2006 at 05:00.

  3. #3

    Default Re: An Intermediate Guide to Scripting

    Is that the full script? Do you have 'script' at the beginning? end_script at the end? Do you have a loop so that the script is still running the next turn?

    If you have all that try getting rid of the campaign_wait commands.
    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: 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.

  5. #5

    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

  6. #6

    Default Re: An Intermediate Guide to Scripting

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

  7. #7

    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.

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