Author Topic: Gumpwaits  (Read 3254 times)

0 Members and 1 Guest are viewing this topic.

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3015
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Gumpwaits
« on: February 17, 2014, 03:59:01 PM »
0
Ok I have some time and I really need to understand how to implement a proper gumpwait. I am using the one that 12XOver posted when he was helping me with gumpwaits and I want to understand how to use it. I have so many script ideas and not enough talent yet to implement them. I am quoting his post from this thread http://www.scriptuo.com/index.php?topic=12006.msg101293#msg101293

I am opening a new thread to make things easier.  8)

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:

Code: [Select]
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.

Code: [Select]
;#######################
;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

Code: [Select]
  set !gName1 %1
   set !gName2 %2
   set !gSize %3
  1) tell me what gump to wait for via name and/or size

Code: [Select]
  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'

Code: [Select]
  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

Code: [Select]
  namespace clear
   namespace pop
Cleanup my namespace

Code: [Select]
return #FALSE   4) tell the rest of the script that it DID NOT come up









So if using this as is, I would use the wait kind of like this?

Code: [Select]
gosub XIIxGumpWait
Would I list a time after like this?

Code: [Select]
gosub XIIxGumpWait 20
On the name part, would this section need to be changed at all?

Code: [Select]
  set !gName1 %1
   set !gName2 %2
   set !gSize %3

I set a gumpsize on my scripts so how would that affect !gName2 %2

Would I need to use %3 on scripts like carpentry which has gumps for tinkering and carpentry?

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Gumpwaits
« Reply #1 on: February 18, 2014, 05:41:34 AM »
0
Hey Crisis!

The reason for a Gumpwait sub is that the time could fluctuate for different people. What might take .1 seconds for you to open a menu could take .6 seconds for me. The idea of a Gumpwait is to say "hang out until you see the "gump" with the following attributes then move along". This way it doesn't matter how long the gump takes to open, you'll be waiting for it.

Quote
Would I list a time after like this?

Code: Select All | Copy To Clipboard
gosub XIIxGumpWait 20
Nope, because you don't really know what the time should be. You want to pass the name of the gump and the size (because the name is usually the same for many gumps) so, for example, if you were using my sub, the gump name was "generic_gump" and the size was 100x100:

Code: [Select]
Gosub XIIxGumpWait generic_gump generic_gump 100_100
Note that my Gumpwait uses two different options for the Gump name (this name OR that name) which is probably not necessary but is an idea I stole from TM's way back when I was still learning and it stuck lol.

Quote
On the name part, would this section need to be changed at all?

Code: Select All | Copy To Clipboard
  set !gName1 %1
   set !gName2 %2
   set !gSize %
I set a gumpsize on my scripts so how would that affect !gName2 %2

You don't change anything in the sub, you pass your variable to it. So, for example, if you set your gump name to something like %CarpMenuName and the size to something like %CarpMenuSize you would call the sub like:

Code: [Select]
gosub XIIxGumpWait %CarpMenuName %CarpMenuName %CarpMenuSize
Quote
Would I need to use %3 on scripts like carpentry which has gumps for tinkering and carpentry?
It's always best to use both the name and the size. When you are using two different skills with identical menu sizes then this can get tricky determining the difference between one or the other so you need to build logic around this in your code but this has no bearing on your gumpwait sub, it's job is ONLY to wait for a gump that you tell it to wait for then report back to the body of the script whether it happened or not.

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: Gumpwaits
« Reply #2 on: February 18, 2014, 03:22:54 PM »
0
Neo have a interesting gumpwait as well in his Ter_mur_lumber or Miner 

Code: [Select]
gosub gumpwait container_gump 144_212 N/A
or
gosub gumpwait N/A N/A %tool_bag
;======= Gumpwait Sub =======
sub gumpwait
  namespace push
  namespace local gumpwait
  set !name %1
  set !size %2
  set !id %3
  set !condcnt 0
  set !nameyes #true
  set !sizeyes #true
  set !idyes #true
  set !timeout #SCNT + 5
  if !name = N/A
  {
    set !condcnt !condcnt + 1
    set !nameyes #false
  }
  if !size = N/A
  {
    set !condcnt !condcnt + 1
    set !sizeyes #false
  }
  if !id = N/A
  {
    set !condcnt !condcnt + 1
    set !idyes #false
  }
  repeat
    if #contname = !name && !nameyes = #true
    {
      set !condcnt !condcnt + 1
      set !nameyes #false
    }
    if #contsize = !size && !sizeyes = #true
    {
      set !condcnt !condcnt + 1
      set !sizeyes #false
    }
    if #contid = !id && !idyes = #true
    {
      set !condcnt !condcnt + 1
      set !idyes #false
    }
  until !condcnt = 3 || #scnt > !timeout
  if !condcnt = 3
  {
    namespace pop
    return #true
  }
  namespace pop
return #false

Must be solid because it work never hang on the gump. :)

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3015
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: Gumpwaits
« Reply #3 on: February 18, 2014, 04:13:57 PM »
0

You don't change anything in the sub, you pass your variable to it. So, for example, if you set your gump name to something like %CarpMenuName and the size to something like %CarpMenuSize you would call the sub like:

Code: [Select]
gosub XIIxGumpWait %CarpMenuName %CarpMenuName %CarpMenuSize
Quote
Would I need to use %3 on scripts like carpentry which has gumps for tinkering and carpentry?
It's always best to use both the name and the size. When you are using two different skills with identical menu sizes then this can get tricky determining the difference between one or the other so you need to build logic around this in your code but this has no bearing on your gumpwait sub, it's job is ONLY to wait for a gump that you tell it to wait for then report back to the body of the script whether it happened or not.

X


Could I do something like this then?

Code: [Select]
gosub XIIxGumpWait CarpMenu CarpMenu 530_497 for carpentry tool

and

Code: [Select]
gosub XIIxGumpWait TinkMenu TinkMenu 530_497
for the tinker tool?

One other question, since this is in your subs section, it is available to use in other's scripts as long as credit is given such as leaving the name SUB XIIxGumpWait?
« Last Edit: February 18, 2014, 04:15:51 PM by Crisis »

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Gumpwaits
« Reply #4 on: February 18, 2014, 07:21:57 PM »
0
Yep, yep again, and yep :)
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: Gumpwaits
« Reply #5 on: February 18, 2014, 09:41:42 PM »
0
Tinkering Menu or carpentry menu  have the same #CONTNAME
#CONTNAME generic_gump  530_497

So you just make up a name 
Code: [Select]
gosub XIIxGumpWait CarpMenu CarpMenu 530_497
or  does the name need to be precise.
Code: [Select]
gosub XIIxGumpWait generic_gump generic_gump  530_497

Tags: