View Full Version : 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.
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:
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
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:
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 :sweatdrop:
The_Mark
10-18-2006, 21:40
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. :juggle2:
Makanyane
04-18-2009, 07:48
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....
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...
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.
HouseOfHam
04-22-2009, 03:37
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.
Makanyane
04-23-2009, 21:15
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:
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..
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 :rolleyes5:
Makanyane
04-29-2009, 22:48
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
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
HouseOfHam
04-30-2009, 18:19
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.
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.