Results 1 to 7 of 7

Thread: Repeating Event - how to?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Repeating Event - how to?

    I have been trying to write a script that fires repeatedly after a set amount of rounds. Example:

    Using GED's 12 turns per year I would like a historic_event to repeat every twelve months (Let's call it Happy_Xmas). December would be in round 11 the first time (round one being turn zero). An easy but exhausting way would be to repeat the event like this:
    Code:
    monitor_event FactionTurnStart FactionIsLocal
        if I_TurnNumber = 11
            historic_event Happy_Xmas
        end_if
    
        if I_TurnNumber = 23
            historic_event Happy_Xmas
        end_if
    
    ;don't terminate since it runs for all events
    end_monitor
    That isn't exactly elegant (and will take upward of 40 entries) and I have been looking into the 'add_event' and 'increase_counter' functions, but I seem to end up with a "perpetuum mobile" that doesn't get of the ground.

    Does anybody have an idea how this can be done?










  2. #2
    konny's Avatar Artifex
    Join Date
    Jul 2007
    Location
    Germania Inferior
    Posts
    3,631

    Default Re: Repeating Event - how to?

    That should be pretty simple:

    Increment a counter every turn by 1, and when the counter has reached 12 fire the event and set the counter back to 0 in the same monitor.

    Team member of: Das Heilige Römische Reich, Europa Barbarorum, Europa Barbarorum II, East of Rome
    Modding help by Konny: Excel Traitgenerator, Setting Heirs to your preference
    dHRR 0.8 beta released! get it here
    New: Native America! A mini-mod for Kingdoms America

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Repeating Event - how to?

    I am bit dull: how would that look like? (the incrementing), please!










  4. #4
    konny's Avatar Artifex
    Join Date
    Jul 2007
    Location
    Germania Inferior
    Posts
    3,631

    Default Re: Repeating Event - how to?

    try this
    Code:
    declare_counter Xmas 
    set_counter Xmas 0
    
    monitor_event FactionTurnStart FactionIsLocal
                        inc_counter Xmas 1
    
                        if I_EventCounter Xmas = 12
                          [do whatever you have planned]
    
                         set_counter Xmas 0
                        end_if
    end_monitor

    Team member of: Das Heilige Römische Reich, Europa Barbarorum, Europa Barbarorum II, East of Rome
    Modding help by Konny: Excel Traitgenerator, Setting Heirs to your preference
    dHRR 0.8 beta released! get it here
    New: Native America! A mini-mod for Kingdoms America

  5. #5
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Repeating Event - how to?

    It is so easy, no wonder I didn't get it. Thanks konny!

    Now how would I get the counter to start in round 4 and stop after round 210?

    Could I put under the monitor_event line the following lines:

    Code:
    monitor_event FactionTurnStart FactionIsLocal
                and I_TurnNumber > 3
                and not I_TurnNumber > 209
    
                inc_counter Xmas 1
    
            if I_EventCounter Xmas = 12
               [do whatever you have planned]
               set_counter Xmas 0
            end_if
    
    end_monitor
    Last edited by Gigantus; October 26, 2009 at 12:43 PM.










  6. #6
    konny's Avatar Artifex
    Join Date
    Jul 2007
    Location
    Germania Inferior
    Posts
    3,631

    Default Re: Repeating Event - how to?

    Yes, I am confident that this should work (I would use "I_TurnNumber < 210" instead, but that's a matter preferences).

    Team member of: Das Heilige Römische Reich, Europa Barbarorum, Europa Barbarorum II, East of Rome
    Modding help by Konny: Excel Traitgenerator, Setting Heirs to your preference
    dHRR 0.8 beta released! get it here
    New: Native America! A mini-mod for Kingdoms America

  7. #7
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Repeating Event - how to?

    Delightful! Let me organize some Xmas.










Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •