That's why a good Gumpwait sub should be able to use both Gumpname and Gumpsize
The issue with relying on Gumpname is that there are so many different gumps called "generic_gump". Adding an optional gumpsize to the wait sub gives that added flexibility for when you really want to make sure.
-----
Crisis - The issue with that first one is that it's not waiting until there is a gump, it's waiting for a 5 count only. What if the gump doesn't come up until the 6 count, well now your script is broken.
A basic gump wait sub needs to follow some basic gump wait logic:
sub gumpwait
1) tell me what gump to wait for via name and/or size
2) set an amount of time to keep looking for the gump before deciding it ain't comin'
3) keep looking for that gump until it either shows up or the amount of time has expired
4) tell the rest of the script what happened
return
This is all my example sub above is doing.
;#######################
;SUB XIIxGumpWait
;#######################
; %1 = Required: Gumpname 1
; %2 = Required only if using Gumpsize: Gumpname 2
; %3 = Optional: Gumpsize
; Returns #TRUE if gump occured before timeout, #FALSE if timeout occured
sub XIIxGumpWait
namespace push
namespace local nsXIIxGumpWait
This is creating the sub and giving it a namespace so that none of it's variables will conflict with the rest of the variables in the script that's calling it
set !gName1 %1
set !gName2 %2
set !gSize %3
1) tell me what gump to wait for via name and/or size
set !_time #SCNT
while #SCNT <= !_time + 5
2) set an amount of time to keep looking for the gump before deciding it ain't comin'
while #SCNT <= !_time + 5
{
if %0 > 2
{
if ( #CONTNAME = !gName1 && #CONTSIZE = !gSize ) || ( #CONTNAME = !gName2 && #CONTSIZE = !gSize )
{
namespace clear
namespace pop
return #TRUE
}
}
else
{
if #CONTNAME = !gName1 || #CONTNAME = !gName2
{
namespace clear
namespace pop
return #TRUE
}
}
}
3) keep looking for that gump until it either shows up or the amount of time has expired
4) tell the rest of the script that it did come up
namespace clear
namespace pop
Cleanup my namespace
return #FALSE
4) tell the rest of the script that it DID NOT come up