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 VirtualWolf's Avatar
    Join Date
    Jun 2006
    Location
    Canada near Toronto
    Posts
    7

    Default Re: An Intermediate Guide to Scripting

    Just a quick note to say thankyou for your guides I am new to modding and they have been invaluable... A great Help .. and because of your writing style I found them easy to understand...
    May the Forest shelter you
    May the wind protect you
    &
    May your packmates
    always answer
    to your call

  2. #2

    Default Re: An Intermediate Guide to Scripting

    I'm new to scripting, so bear with me.

    I want a script that gives the other factions (non player) money every turn, extra depending on the state of their economy.

    Would this work? (I'm having troubles getting mods to work at the moment, so I cant test it)
    Code:
    script
    declare_counter loop
    set_counter loop 0
    
    monitor_event FactionTurnStart 
    and not FactionIsLocal
    
    console_command add_money 2000
    
    end_monitor
    
    monitor_event FactionTurnStart 
    and not FactionIsLocal
    and Treasury < 2000
    
    console_command add_money 2000
    
    end monitor
    
    monitor_event FactionTurnStart 
    and not FactionIsLocal
    and Treasury < 5000
    
    console_command add_money 2000
    
    end monitor
    
    while I_CompareCounter loop = 0
    end_while
    end_script
    Thanks
    Last edited by Psyco; 01-16-2007 at 06:26.
    Anyone who has no fear of death himself can succeed in inflicting it.
    The Prince,
    Machiavelli

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

    Post Re: An Intermediate Guide to Scripting

    Your script won't work as you intend. When no faction is specified, the add_money console command puts the specified funds in the player's treasury.

    You need to repeat each of your monitors for every faction and specify the faction name in the add_money console command:

    Code:
    monitor_event FactionTurnStart FactionType seleucid
                        and not FactionIsLocal
    
    console_command add_money seleucid, 2000
    
    end_monitor
    
    monitor_event FactionTurnStart FactionType spain
                        and not FactionIsLocal
    
    console_command add_money spain, 2000
    
    end_monitor
    
    ...(et cetera)
    This need for duplication is responsible for the EB background script running to over 165,000 lines of code.
    The truth is the most valuable thing we have. Let us economize it. - Mark Twain



  4. #4

    Default Re: An Intermediate Guide to Scripting

    Thanks for the help.

    Is there any list that shows which versions of the names I should be using? I would assume the ones at the top of descr_strat.txt, but it never hurts to ask.

    I'm doing this for Medieval II, but I've heard the architecture is nearly identical, so it shouldn't matter.
    Last edited by Psyco; 01-17-2007 at 03:31.
    Anyone who has no fear of death himself can succeed in inflicting it.
    The Prince,
    Machiavelli

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

    Default Re: An Intermediate Guide to Scripting

    Quote Originally Posted by Psyco
    ... which versions of the names I should be using? I would assume the ones at the top of descr_strat.txt...
    Yes, that's right. M2TW has the faction names in descr_strat.txt too.
    The truth is the most valuable thing we have. Let us economize it. - Mark Twain



  6. #6

    Default Re: An Intermediate Guide to Scripting

    Thanks for all the help. I appreciate it.
    Anyone who has no fear of death himself can succeed in inflicting it.
    The Prince,
    Machiavelli

  7. #7

    Default Re: An Intermediate Guide to Scripting

    Hi all. I want to write a script to achieve this result: Every time I press the "disband unit" button, it will create a certain unit in a certain city.



    Code:
    script
    
    declare_counter loop
    set_counter loop 1
     
    monitor_event ButtonPressed ButtonPressed disband_unit
    console_command create_unit  Bordeaux "Dismounted Feudal Knights80" 1
    end_monitor
     
    while I_CompareCounter loop = 1
    end_while
    
    end_script
    As you can see, the problem is I don't know what the real button ID of "disband unit". The CA docudemon says it can be found in a file called available_ui_elements.txt. But where can I find it?

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