Results 1 to 30 of 42

Thread: Can I use a script to end the turn?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Can I use a script to end the turn?

    mrtwisties, apologies if I've slightly lost track of where you've got to with this.

    Does your version give you an autosave you can re-load do you know?

    I'm running testing at the moment with script automatically launched from campaign script and then also triggering ER's year jump script to go on 200 turns (BI mod), that works fine for balance issues, but I'm getting occassional CTD about 140 turns in which is probably script generated unfortunately. It autosaves whilst on year jump but save doesn't seem to know who you are so crashes if trying to re-load. I could really do with being able to re-load before CTD as never manage to be watching campaign at right point to see what problem area is otherwise. (watching campaign prevents CTD occuring, it just happens as soon as you get distracted! )
    Not used mods before? Looking for something small and fun?!
    Download the:

  2. #2
    Member Member mrtwisties's Avatar
    Join Date
    Nov 2007
    Location
    Sydney, Australia
    Posts
    235

    Default Re: Can I use a script to end the turn?

    Hey Makanyane. It's neither implemented nor tested yet, but for that very reason I've mocked up some code that auto-saves once every four turns.

    I'm still working on getting the core module working. I've reworked it so that hopefully it can be spliced into another script (like the EB background script) and still function, but I still need to find a way to auto-resolve diplomacy and auto-dismiss the battle results screen. Here's what the script looks like:

    script

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;Jumpity Jumpity Jump Jump Jump
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    declare_counter loop
    declare_counter clickAutoResolve
    declare_counter DismissScroll
    declare_counter declineDiplomaticOffer
    set_counter loop 0
    set_counter clickAutoResolve 0
    set_counter DismissScroll 0
    set_counter declineDiplomaticOffer 0
    ;
    monitor_event FactionTurnStart FactionType romans_julii
    and I_CompareCounter loop < 4
    console_command clear_messages
    console_command control greek_cities
    end_monitor
    ;
    monitor_event FactionTurnStart FactionType greek_cities
    and I_CompareCounter loop < 4
    console_command clear_messages
    console_command control romans_julii
    inc_counter loop 1
    end_monitor
    ;
    monitor_event PreBattlePanelOpen TrueCondition
    and I_CompareCounter loop < 4
    set_counter clickAutoResolve 1
    end_monitor
    ;
    monitor_event NavalAutoResolvePanelOpen TrueCondition
    and I_CompareCounter loop < 4
    set_counter clickAutoResolve 1
    end_monitor
    ;
    monitor_conditions I_CompareCounter clickAutoResolve = 1
    set_counter clickAutoResolve 0
    select_ui_element prebattle_auto_resolve_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up
    end_monitor
    ;
    monitor_event ScrollOpened ConditionTrue
    and I_CompareCounter loop < 4
    set_counter DismissScroll 1
    end_monitor
    ;
    monitor_conditions I_CompareCounter DismissScroll = 1
    set_counter DismissScroll 0
    select_ui_element confirm_quit_scroll
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up
    end_monitor

    ;
    ;None of this diplomacy stuff works
    ;
    ;monitor_event ScrollOpened diplomacy_scroll
    ;set_counter declineDiplomaticOffer 1
    ;end_monitor
    ;
    ;monitor_event DiplomacyPanelOpen TrueCondition
    ;set_counter declineDiplomaticOffer 1
    ;end_monitor
    ;
    ;monitor_conditions I_CompareCounter declineDiplomaticOffer = 1
    ;set_counter declineDiplomaticOffer 0
    ;select_ui_element confirm_quit_scroll

    ;simulate_mouse_click lclick_down
    ;simulate_mouse_click lclick_up
    ;end_monitor
    ;
    monitor_conditions I_CompareCounter loop = 4
    console_command control egypt
    console_command clear messages
    terminate_monitor
    end_monitor

    while loop < 5
    end_while

    end_script
    I can't even get the diplomacy or battle-result monitors working, at the moment. Haven't really had a chance to make any progress in the last few days, though.

  3. #3
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Can I use a script to end the turn?

    In addition to what you had with slight adjustment:
    monitor_event DiplomacyPanelOpen TrueCondition
    set_counter declineDiplomaticOffer 1
    end_monitor

    monitor_conditions I_CompareCounter declineDiplomaticOffer = 1
    set_counter declineDiplomaticOffer 0
    select_ui_element diplomacy_decline_offer_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up
    end_monitor
    declines the diplomacy offer, I just can't figure out how to quit the scroll
    I think the one you're trying to use
    select_ui_element confirm_quit_scroll
    is actually the "do you really want to leave the game, yes or no" scroll
    but can't figure out what button for just escaping scroll actually is
    Not used mods before? Looking for something small and fun?!
    Download the:

  4. #4
    Member Member mrtwisties's Avatar
    Join Date
    Nov 2007
    Location
    Sydney, Australia
    Posts
    235

    Default Re: Can I use a script to end the turn?

    I know what you mean. Have mostly got the monitors working. But I think I've tried every single ui_element that looks even vaguely like it might work to close those scrolls. I've even been making up names!

    Am no longer convinced that this approach can work. Might try:

    1. Using another utility to automate pressing "enter" and "esc" every few seconds. These keypresses would be sufficient to kick things along, but I don't think you'd be able to do anything else with the computer while the year jump was taking place. Not sure, I've never used a utility like that before. Hmmm, I haven't actually tried telling the RTW script to press keys, so maybe that's also worth a go. There do seem to be some key names in descr_shortcut.txt.

    2. Using campaign scripts to try and unlock the features that are suppressed by the -ai switch. Using "console_command control factionname" in a campaign script does give you control - but it means that show_me scripts don't work thereafter. Maybe there's a way of fixing that? It'd be good if there was.

    3. Killing a faction, switching control to it and then having that faction "re-emerge" (ie "capture_settlement") later in the game. Clearly a sub-optimal solution.

    4. Using emergent factions and ER's BI-based year jump mod. My least favourite approach.

  5. #5
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Can I use a script to end the turn?

    Quote Originally Posted by mrtwisties
    3. Killing a faction, switching control to it and then having that faction "re-emerge" (ie "capture_settlement") later in the game. Clearly a sub-optimal solution.

    Not really sure if that will work, afaik once a faction is dead it can be respawned, but so far I've been unable to "re-activate" it (they're arent doing a thing ...)


    G

  6. #6
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Can I use a script to end the turn?

    1. Using another utility to automate pressing "enter" and "esc" every few seconds. These keypresses would be sufficient to kick things along, but I don't think you'd be able to do anything else with the computer while the year jump was taking place. Not sure, I've never used a utility like that before. Hmmm, I haven't actually tried telling the RTW script to press keys, so maybe that's also worth a go. There do seem to be some key names in descr_shortcut.txt.
    not sure on external utility - if you hit esc when there isn't screen to close you'll be going in and out of the menu screen. If you can do it inside script it would work though with a wait after the resolve event but within the same monitor.

    4. Using emergent factions and ER's BI-based year jump mod. My least favourite approach.
    Well, that was where I was, works to test balance to end of fixed period (assuming you have spare factions), is compatible with background script if you launch year jump from trigger in bg script. Just doesn't get you usable autosave

    That seems to be main snag - to get a usable save it has to be legitimately your turn, if its your (human controlled) turn you get the closing scroll problem.
    Not used mods before? Looking for something small and fun?!
    Download the:

  7. #7
    Member Member mrtwisties's Avatar
    Join Date
    Nov 2007
    Location
    Sydney, Australia
    Posts
    235

    Default Re: Can I use a script to end the turn?

    Quote Originally Posted by Makanyane
    not sure on external utility - if you hit esc when there isn't screen to close you'll be going in and out of the menu screen. If you can do it inside script it would work though with a wait after the resolve event but within the same monitor.
    Have been busy for the last few days, but was thinking of "stealing" the escape key, except for when one of those pesky scrolls pops up.

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