Results 1 to 20 of 20

Thread: Intermediate Guide to Scripting Discussion

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Simulation Monkey Member The_Mark's Avatar
    Join Date
    Dec 2004
    Location
    Helsinki, Finland
    Posts
    2,613

    Default Re: Intermediate Guide to Scripting Discussion

    Adding a thing about condition monitors and counters, the I_CompareCounter can be placed in an if just after the monitor. Much neater than using two monitors,a nd much simpler, too. Prolly that's why I didn't think of it earlier.

    Code:
    monitor_conditions condition
    if I_CompareCounter
    stuff
    end_if
    end_monitor

  2. #2
    Senior Member Senior Member Duke John's Avatar
    Join Date
    May 2003
    Location
    Netherlands
    Posts
    2,917

    Default Re: Intermediate Guide to Scripting Discussion

    I am trying to test the value of a character's trait during a turn and I had hoped that the following would work:

    script

    Code:
    console_command give_trait Barrivendos GoodCommander
    
    monitor_conditions not I_CharacterSelected Barrivendos
    and Trait GoodCommander >= 1
    	console_command give_trait Barrivendos GoodAttacker
    terminate_monitor
    end_monitor
    
    end_script
    But it does not Can anyone see what is wrong?

    Barrivendos does get the GoodCommander trait which should have a value of 1. Then the not I_CharacterSelected Barrivendos should put the focus on the character which then allows testing the value of the GoodCommander trait. Or doesn't it work like that?

    Any help would be greatly appreciated!

  3. #3
    Simulation Monkey Member The_Mark's Avatar
    Join Date
    Dec 2004
    Location
    Helsinki, Finland
    Posts
    2,613

    Default Re: Intermediate Guide to Scripting Discussion

    What you need to get the Trait condition work is an exported character_record, and condition monitors don't export values; you'll need an event monitor, and convenient events to do that are far and few between.

  4. #4
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: Intermediate Guide to Scripting Discussion

    I don't think it's possible except through CharacterSelected which involves that the player does something and the character is on the map.
    You might also consider using a show_me

  5. #5

    Default Re: Intermediate Guide to Scripting Discussion

    I have a question regarding scripts.

    I'm trying to get a show_me script to run from a background script, but it doesn't seem to be working. This is similar to the Client Kingdoms mod implemented into the TFT mod. The background script works fine and all other functions within it work as intended. Here is the background script section that is supposed to start the show_me script:

    Code:
    monitor_event SettlementTurnStart SettlementName Rome
    	and SettlementIsLocal
    	and Treasury > 5000
    	advance_advice_thread Recruit_Legion_Thread
    end_monitor
    This is just temporary until I can get it working - then I'll tweak the costs and add a RandomPercent. Here is the advice thread it refers to:

    Code:
    AdviceThread Recruit_Legion_Thread
        GameArea Campaign
        
        Item Recruit_Legion
        		Uninhibitable
        		Verbosity  0 
        		Threshold  1  
        		Attitude Normal
        		Presentation Default
        		Title Recruit_Legion_Title
         	Script scripts\show_me\recruit_roman_legion.txt
    		Text Recruit_Legion_Text1
    And yes, I have set up the text. Finally, here is the whole show_me script:

    Code:
    script
    console_command create_unit Rome "roman hastati" 2
    console_command create_unit Rome "roman princeps" 2
    console_command create_unit Rome "roman velite" 2
    console_command create_unit Rome "roman Triarii" 1
    console_command create_unit Rome "roman light cavalry" 1
    console_command add_money -5000
    console_command add_population Rome -1210
    
    select_ui_element advisor_dismiss_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up
    
    terminate_script
    end_script
    Can anyone see what I'm doing wrong here? I've tried changing it so that the script runs when Rome is selected using I_SettlementSelected SettlementName Rome but no dice...

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

    Default Re: Intermediate Guide to Scripting Discussion

    Well, perhaps it's a silly answer, but the first possible mistake is "roman Triarii" instead of "roman triarii".

    The second point is that I cannot see the need for a background script only for this purpose. It would be enough with a normal trigger in export_descr_advice, as in Client Kingdoms mod.

    Third point: Did you try the final script without the authomatic "button pressing"?

    You should include some "mark" just to know where the method is failing.

    Good luck!

  7. #7

    Default Re: Intermediate Guide to Scripting Discussion

    When you say not working, does the advisor come up at all? Do you have entries in text\export_advice for that advice thread?
    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

  8. #8

    Default Re: Intermediate Guide to Scripting Discussion

    Well, perhaps it's a silly answer, but the first possible mistake is "roman Triarii" instead of "roman triarii".
    Didn't think of that. I'll fix it an give it a go.

    The second point is that I cannot see the need for a background script only for this purpose. It would be enough with a normal trigger in export_descr_advice, as in Client Kingdoms mod.
    Sorry, I didn't make it clear. I'm running a background script for a whole lot of things - such as 4tpy, historical events and such. I wanted to add this as a show_me script from the background script as the background script has the "suspend_unscripted_advice true" line added (otherwise I couldn't stop the script from continuously reloading).

    Third point: Did you try the final script without the authomatic "button pressing"?
    Good point, I'll give it a go if the Triarii typo doesn't fix it.

    You should include some "mark" just to know where the method is failing.
    Not entirely sure what you mean, or how to do it.

    When you say not working, does the advisor come up at all? Do you have entries in text\export_advice for that advice thread?
    Advisor doesn't even come up. Yes, as I said earlier, I have the text set up properly.

    Thanks for the help, guys, I'll give the script another go with a few changes.

    AFAIK RTW doesn't support multiple scripts running side by side; you'll have to include the event script in the background script in an event_monitor ButtonPressed ButtonPressed advisor_button_of_choice (excluding show_me button - no multiple scripts -> no script running -> no registered click on the button, or something to that effect; this limits the button quite surely to advisor_portrait_button).
    Good point, but I could have sworn that the TFT mod made this work...
    Last edited by Cheexsta; 12-07-2005 at 14:52.

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