Results 1 to 9 of 9

Thread: what is wrong with this ui_elements script?

  1. #1

    Default what is wrong with this ui_elements script?

    Could somebody help me with this script?
    I want that everytime the loot_settlement_scroll is opened, the script automatically select the ocuppy option.

    Code:
    monitor_event ScrollOpened ScrollOpened loot_settlement_scroll
       ;console_command puppify_my_love
       ;wait 1
       select_ui_element loot_settlement_occupy_button
       simulate_mouse_click lclick_down
       simulate_mouse_click lclick_up
    end_monitor
    The monitor event is detected correctly (puppify_my_love is executed), but the option is not selected nor clicked. I have tested adding some "wait" commands, but with no results. I have also tested this:

    Code:
    monitor_event ScrollOpened ScrollOpened prebattle_scroll
       select_ui_element prebattle_auto_resolve_button
       simulate_mouse_click lclick_down
       simulate_mouse_click lclick_up
    end_monitor
    Any ideas? Has somebody been able to get working some similar script?
    Thanks

  2. #2

    Default Re: what is wrong with this ui_elements script?

    Sorry the double post, but after MANY tries, I have finally found a way to get it working. I put my solution here, for if somebody had the same doubt:

    Code:
    script
    
    declare_counter player
    set_counter player 1
    declare_counter scroll
    set_counter scroll 0
    
    monitor_event FactionTurnStart FactionIsLocal
       set_counter player 1
    end_monitor
    monitor_event FactionTurnEnd FactionIsLocal
       set_counter player 0
    end_monitor
    
    monitor_event ScrollOpened ScrollOpened loot_settlement_scroll
       set_counter scroll 1
    end_monitor
    
    monitor_conditions I_CompareCounter player = 1
       if I_CompareCounter scroll = 1
          set_counter scroll 0
          select_ui_element loot_settlement_occupy_button
          simulate_mouse_click lclick_down
          simulate_mouse_click lclick_up
       end_if
    end_monitor
    
    while TrueCondition
    end_while
    
    end_script
    NOTE: I also did many tries before I write this topic, and I believed that I would not be able to solve it without help

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

    Default Re: what is wrong with this ui_elements script?

    If you didn't have that endless while loop at the end of your first script it might have caused the script to terminate prematurely, leading to no monitor getting fired, ever, but if you got results with puppify then the bugger does indeed require a conditions monitor.

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

    Default Re: what is wrong with this ui_elements script?

    Sorry about the long range bump - but many thanks to Bardo for showing the solution to this initial problem - I've been having a lot of problems with trying to disable the loot_settlement exterminate option, this worked to force occupation, but I think I've finally found a fix that actually only disables the exterminate option as a variation....

    Code:
    declare_counter player
    declare_counter scroll
    set_counter scroll 0
    
    monitor_event FactionTurnStart FactionIsLocal
        	if I_LocalFaction greek_cities
       		set_counter player 1
    	end_if
    end_monitor
    
    monitor_event FactionTurnEnd FactionIsLocal
       set_counter player 0
    end_monitor
    
    monitor_event ScrollOpened ScrollOpened loot_settlement_scroll
       set_counter scroll 1
    end_monitor
    
    
    monitor_conditions I_CompareCounter player = 1
       if I_CompareCounter scroll = 1
    	while I_ScrollOpened
          	set_counter scroll 0
    	disable_ui loot_settlement_extermintate_button
    	end_while
       end_if
    end_monitor
    I'd thought that the disable_ui bit wasn't working but finally realised it was just too quick and needed a while to keep it disabled while the scroll is opened - I_ScrollOpened wasn't in the docs as such but is only thing that seems to work there.

    If anyone is still having problems with disabling the auto-resolve button I wonder if similar principle might work? EDIT: gah - just tried and it doesn't seem to work on the auto-resolve button...
    Last edited by Makanyane; 04-18-2009 at 08:14.
    Not used mods before? Looking for something small and fun?!
    Download the:

  5. #5

    Default Re: what is wrong with this ui_elements script?

    I'm glad it helped you.
    I also tried to use disable_ui with no luck. Thank you for sharing your new version because it was exactly what I was trying to achieve the first time, and your solution will still be useful for our mod.

  6. #6

    Default Re: what is wrong with this ui_elements script?

    About I_ScrollOpened - there is no such condition in the .exe.

    It's probably just grabbing whatever value is on the top of the stack, which is probably non-zero so it evaluates to true. Then, doing set_counter scroll 0 probably pushes the 0 on stack and the while loop exits...

    Try changing it to "while EarthIsFlat". If it still works, it's a pretty good indication that's what's going on.
    RTR VII Developer

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

    Default Re: what is wrong with this ui_elements script?

    Ugh - you're right FlatEarth has same effect - basically it works to disable the button if the initial condition is met - but then stays disabled for rest of game whilst script is loaded... that's possibly ok for me as all i really want is if you're Greeks you can't exterminate but does mean other conditions to re-enable extermination wouldn't work.

    tried:
    Code:
    declare_counter scroll
    set_counter scroll 0
    
    monitor_event ScrollOpened ScrollOpened loot_settlement_scroll
       set_counter scroll 1
    end_monitor
    
    
    monitor_conditions I_LocalFaction greek_cities
       if I_CompareCounter scroll = 1
    	while I_CompareCounter scroll = 1
    	disable_ui loot_settlement_extermintate_button
    	end_while
       terminate_monitor
       end_if
    end_monitor
    
    monitor_event ScrollClosed ScrollClosed  loot_settlement_scroll
       set_counter scroll 0
    end_monitor
    which looks more like it should be valid code - first occupation works fine, then you'd think terminate_monitor would return you to normal after it switched off but next sieges resulted in exterminate and occupy buttons being disabled, which is kind of weird and not useful..

    Code:
    declare_counter scroll
    set_counter scroll 0
    
    monitor_event ScrollOpened ScrollOpened loot_settlement_scroll
       set_counter scroll 1
    end_monitor
    
    
    monitor_conditions I_LocalFaction greek_cities
       if I_CompareCounter scroll = 1
    	while TrueCondition
          	set_counter scroll 0
    	disable_ui loot_settlement_extermintate_button
    	end_while
       end_if
    end_monitor
    is reduced down version of what its really doing (am not sure the set_counter to 0 is actually turning off though) attempts to move the reset to a scroll closed condition just result in the occupy and exterminate buttons being disabled as above
    Not used mods before? Looking for something small and fun?!
    Download the:

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

    Default Re: what is wrong with this ui_elements script?

    have finally got this to behave with what I think is a valid condition (not just ConditionTrue) - anyway it will now switch on and off according to setting of scroll counter if required

    Code:
    declare_counter scroll
    set_counter scroll 0
    
    ;;use this version to apply to all settlements
    ;monitor_event ScrollOpened ScrollOpened loot_settlement_scroll
    ;   set_counter scroll 1
    ;end_monitor
    
    ;use this version for named settlement
    monitor_event GeneralCaptureSettlement FactionType greek_cities
       and SettlementName Athens
       set_counter scroll 1
    end_monitor
    
    monitor_conditions I_LocalFaction greek_cities
       if I_CompareCounter scroll = 1
    	while I_CompareCounter scroll = 1
    	disable_ui loot_settlement_extermintate_button
    	end_while
       end_if
    end_monitor
    
    monitor_event ButtonPressed ButtonPressed loot_settlement_occupy_button
    	enable_entire_ui
       	set_counter scroll 0
    end_monitor
    
    monitor_event ButtonPressed ButtonPressed loot_settlement_enslave_button
    	enable_entire_ui
       	set_counter scroll 0
    end_monitor
    it needs enable_entire_ui when either of the available loot buttons is pressed to get it to switch off properly - trying to use ScrollClosed or enable_ui loot_settlement_extermintate_button doesn't work but above seems to
    Not used mods before? Looking for something small and fun?!
    Download the:

  9. #9

    Default Re: what is wrong with this ui_elements script?

    I'm at work, so I can't test my ideas right now, but it may be possible to simplify this a little.

    edit: Sorry, didn't get to try this yesterday. Was busy moving RTR:FOE to a new Subversion repository.
    Last edited by HouseOfHam; 05-01-2009 at 17:26.
    RTR VII Developer

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