Author Topic: Help with Tinkering section of a script please  (Read 4401 times)

0 Members and 1 Guest are viewing this topic.

Offline CushTopic starter

  • Sr. Member
  • *
  • Posts: 281
  • Activity:
    0%
  • Reputation Power: 4
  • Cush has no influence.
  • Respect: +42
  • Referrals: 0
    • View Profile
Help with Tinkering section of a script please
« on: June 29, 2015, 08:38:13 AM »
0
Hi All,

I have working with a mining script the last couple of year that I found and tailored parts of it to fit my needs. I have had one on going error since the beginning which I just can not seem to get tracked down.

The script tinkers its own shovels and when the tinkering tools get down it makes new tinkering tool kits. The problem is that it fills the back pack with them! lol

I think its missing a counter or stop but I can not seem to figure it out. If you could take a look and tell me what is missing I would greatly appreciate it.

Thanks!

Code: [Select]
;*****************************************
;******** Tinkering
;*****************************************
; ** FindShovel **
; Tries to find a shovel, if non are found will initial
; tinkering or recall back to home base
Sub FindShovel
   GoSub UpdateStatusWindow FindShovel
   FindShovelStart:
      GoSub CheckEscapeStatus
      If %CheckEscapeStatus
         Return

      GoSub FindUsableMiningTool %BackpackId
      If #FindId = X
      {
         if %UseTinkering
         {
            If %TinkerSkill >= 900
               Set %_fsIngotsNeeded 10
            Else
               Set %_fsIngotsNeeded 20
            FindItem %IngotType C_ , %BackpackId
            If #FindKind = -1 || #FindStack < %_fsIngotsNeeded
               GoSub UnloadAtBase #false
            GoSub MakeShovel
            Goto FindShovelStart
         }
         if ! %UseTinkering
         {
            GoSub UnloadAtBase #false
            Goto FindShovelStart
         }
      }
Return

; ** MakeShovel **
; Will make 1-2 shovels using tinkering - Using the menus or
; UOA macros if they have been setup
Sub MakeShovel
   GoSub CheckEscapeStatus
   If %CheckEscapeStatus
      Return

   Set %_msTimeStart #sCnt2
   GoSub UpdateStatusWindow MakeShovel

   FindItem %TinkerType C_ , %BackpackId
   Wait 5
   If #FindKind <> -1 && #FindCnt = 1
   {
      If %UOATinkerToolKey <> N/A
      {
         Key %UOATinkerToolKey %UOATinkerToolMod
         Wait %UOATinkerToolWait
      }
      If %UOATinkerToolKey = N/A
      {
         GoSub BringUpTinkerMenu #FindId
         Wait 10
         GoSub ClickTinkerButton 30 135
         If %return
            GoSub ClickTinkerButton 230 130
         Set %LastMadeWasShovel #false
      }
   }
   FindItem %TinkerType C_ , %BackpackId
   If #FindKind <> -1
   {
      If %UOAShovelKey <> N/A
      {
         Key %UOAShovelKey %UOAShovelMod
         Wait %UOAShovelWait
      }
      If %UOAShovelKey = N/A
      {
         GoSub BringUpTinkerMenu #FindId
         If %LastMadeWasShovel  ; If the last thing we made was a shovel, its easy!
            GoSub ClickTinkerButton 285 455
         If ! %LastMadeWasShovel
         {
            GoSub ClickTinkerButton 380 290
            If %Return
            {
               GoSub ClickTinkerButtonNext
               GoSub ClickTinkerButton 380 290
            }
         }
         If %return
         {
            Set %LastMadeWasShovel #true
            If %MakeTwoShovels
               GoSub ClickTinkerButton 285 455
         }
      }
      Set %_msCancelX #ContPosX + 10
      Set %_msCancelY #ContPosY + 10
      Click %_msCancelX %_msCancelY R ; Close tinker menu
   }
   GoSub RecordTiming %_msTimeStart MakeShovel
Return

; ** ClickTinkerButton **
Sub ClickTinkerButton
   Set %_ctbX %1 + #ContPosX
   Set %_ctbY %2 + #ContPosY
   Click %_ctbX %_ctbY
   Gosub waitForSysVar contSize <> 530_497 30
   Gosub waitForSysVar contSize = 530_497 30
   Wait 5
Return

; ** ClickTinkerButtonNoWait **
Sub ClickTinkerButtonNext
   Set %_ctbnX 385 + #ContPosX
   Set %_ctbnY 270 + #ContPosY
   Click %_ctbnX %_ctbnY F
   Wait 2s
Return

; ** BringUpTinkerMenu **
; Lag resistant opening of tinker menu
; Parameter 1: ID of tinker tool
Sub BringUpTinkerMenu
   Set %_butmTinkerTool %1
   Wait 5 ; A lot of times the tinker tool usage get 'You must wait...'
   _butmTinkerMenu:
      GoSub UseObject %_butmTinkerTool #false #false
      Gosub waitForSysVar contSize = 530_497 30
      if ! %return
         goto _butmTinkerMenu
Return

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: Help with Tinkering section of a script please
« Reply #1 on: June 29, 2015, 09:57:24 AM »
0
For starters, yuck! LOL.

Are you using all that UOAKey logic? There's a lot more going on there than what really needs to be.

What is the "FindUsableMiningTool" sub? That seems to be missing in your post, or I'm blind which is also likely.

<update>
I'm curious why "   Gosub waitForSysVar contSize <> 530_497 30" is in the ClickTinkerButton sub before "   Gosub waitForSysVar contSize = 530_497 30", seems like that's a bit of a waste of time every time. Also, I don't see %return getting set anywhere so all of the "If %return" statements are unnecessary.

Another oddity is that it doesn't look like the script will ever close the tinker gump unless it successfully makes a shovel.

THEN there's this gem -

Code: [Select]
GoSub ClickTinkerButton 380 290
If %Return
{
GoSub ClickTinkerButtonNext
GoSub ClickTinkerButton 380 290
}

So first, it clicks the Next button (380 290) then it calls the ClickTinkerButtonNext sub which does EXACTLY the same thing only to then click 380 290 yet again LOL.

This thing is a bit of a mess, honestly I think the real question is why does this work at all :D

Still haven't nailed why it keeps making tinker tools over and over though, been having fun poking at it with my smelting stick (yes this is a Harry Potter reference).

XII
« Last Edit: June 29, 2015, 10:25:26 AM by 12TimesOver »
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 CushTopic starter

  • Sr. Member
  • *
  • Posts: 281
  • Activity:
    0%
  • Reputation Power: 4
  • Cush has no influence.
  • Respect: +42
  • Referrals: 0
    • View Profile
Re: Help with Tinkering section of a script please
« Reply #2 on: June 29, 2015, 10:11:40 AM »
0
lol no i don't use any of the UOA stuff. I just haven't deleted all that just in case I screw it up lol

This is an old mining script I use and just started adjusting more towards myself in regards to what I wanted to do. It was suggested to me years ago.

is this what you are looking for.



Code: [Select]
Sub FindUsableMiningTool
   _fumtLoop:
      FindItem %DiggingTools C_ , %BackpackId
      If #FindKind <> -1
      {
         GoSub IsUsableMiningTool
         If ! #Result
         {
            IgnoreItem #FindId
            goto _fumtLoop
         }
      }
   IgnoreItem Reset
Return #FindId

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: Help with Tinkering section of a script please
« Reply #3 on: June 29, 2015, 10:56:49 AM »
0
You could use this replacement sub instead, although I'm just whipping through while taking a much needed distraction break at work and it is far from tested. I cleaned up the old sub and put in my own logic and sub calls while trying to keep the rest the same so it still fits in the script you're using, although I can't guarantee anything. Maybe it will at least help to see. This comes with no warranty :)

Code: [Select]
Sub FindShovel
   GoSub UpdateStatusWindow FindShovel
   GoSub CheckEscapeStatus
   If %CheckEscapeStatus
      Return

   repeat
      Finditem %DiggngTools C_ , %BackpackId
      If #FindCnt < 2 && %UseTinkering = #FALSE
         GoSub UnloadAtBase #false
      If #FindCnt < 2 && %UseTinkering = #TRUE
         {
         FindItem %IngotType C_ , %BackpackId
         If #FindKind = -1 || #FindStack < 20
            GoSub UnloadAtBase #false
        
         repeat
            FindItem %TinkerType C_ , %BackpackId
            If #Findkind <> -1 && If #FindCnt < 2
            gosub XIIxTinker Tools
         until #FindCnt > 1

         repeat
            FindItem %TinkerType C_ , %BackpackId
            If #Findkind <> -1 && If #FindCnt < 2
               gosub XIIxTinker Shovel
         until #FindCnt > 1
         }
      Finditem %DiggngTools C_ , %BackpackId
   until #Findcnt > 1
Return

Then use my subs:

Code: [Select]
;####################
;SUB XIIxTinker
;####################
sub XIIxTinker
   namespace push
   namespace local nsXIIxTink
   set !ItemToMake %1
   set !TinkerToolTypes JTL_GTL_KTL
   set !CraftGumpSize 530_497
   repeat
      finditem !TinkerToolTypes C_ , #backpackid
      set #lobjectid #findid
      event macro 17
      gosub XIIxGumpWait generic_gump generic_gump !CraftGumpSize
   until #RESULT = #TRUE
  
   if !TinkerLast = !ItemToMake
      {
      gosub XIIxClickNWait 280 450 #TRUE generic_gump !CraftGumpSize ;make last
      gosub XIIxClickNWait 30 450 #FALSE ;exit
      return
      }
   if !ItemToMake = Tools
      {
      set !TinkerLast Tools
      gosub XIIxClickNWait 30 130 #TRUE generic_gump !CraftGumpSize ;tools
      gosub XIIxClickNWait 230 130 #TRUE generic_gump !CraftGumpSize ;tinker tools
      gosub XIIxClickNWait 30 450 #FALSE ;exit
      }
   if !ItemToMake = Shovel
      {
      set !TinkerLast Shovel
      gosub XIIxClickNWait 30 130 #TRUE generic_gump !CraftGumpSize ;tools
      gosub XIIxClickNWait 380 270 #TRUE generic_gump !CraftGumpSize ;next
      gosub XIIxClickNWait 230 70 #TRUE generic_gump !CraftGumpSize ;shovel
      gosub XIIxClickNWait 30 450 #FALSE ;exit
      }
   namespace pop
return

;#######################
;SUB XIIxClickNWait
;#######################
; %1 = Required: Xoffset
; %2 = Required: Yoffset
; %3 = Required: #TRUE to wait for gump, any other value to return after click
; %4 = Required if %3 is #TRUE: Gump_Name
; %5 = Required if %3 is #TRUE: Gump_Size
sub XIIxClickNWait
   namespace push
   namespace local nsXIIxClickNWait
   set !clickx #contposx + %1
   set !clicky #contposy + %2
   set !gName1 %4
   set !gName2 %4
   set !gSize %5
   click !clickx !clicky
   if %3 <> #TRUE
      {
      namespace clear
      namespace pop
      return
      }
   if %0 > 3
      gosub XIIxGumpWait !gName1 !gName2 !gSize
   namespace clear
   namespace pop
return

;#######################
;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
   wait 10
   set !gName1 %1
   set !gName2 %2
   set !gSize %3
   set !_time #SCNT
   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
            }
         }
      }
   namespace clear
   namespace pop
return #FALSE
« Last Edit: June 29, 2015, 11:07:10 AM by 12TimesOver »
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: Help with Tinkering section of a script please
« Reply #4 on: June 29, 2015, 12:56:52 PM »
0
Cush,    This should fix the problem you having

Code: [Select]
;*****************************************
;******** Tinkering
;*****************************************
; ** FindShovel **
; Tries to find a shovel, if non are found will initial
; tinkering or recall back to home base
Sub FindShovel
   GoSub UpdateStatusWindow FindShovel
   FindShovelStart:
      GoSub CheckEscapeStatus
      If %CheckEscapeStatus
         Return

      GoSub FindUsableMiningTool %BackpackId
      If #FindId = X
      {
         if %UseTinkering
         {
            If %TinkerSkill >= 900
               Set %_fsIngotsNeeded 10
            Else
               Set %_fsIngotsNeeded 20
            FindItem %IngotType C_ , %BackpackId
            If #FindKind = -1 || #FindStack < %_fsIngotsNeeded
               GoSub UnloadAtBase #false
            GoSub MakeShovel
            Goto FindShovelStart
         }
         if ! %UseTinkering
         {
            GoSub UnloadAtBase #false
            Goto FindShovelStart
         }
      }
Return

; ** MakeShovel **
; Will make 1-2 shovels using tinkering - Using the menus or
; UOA macros if they have been setup
Sub MakeShovel
   GoSub CheckEscapeStatus
   If %CheckEscapeStatus
      Return

   Set %_msTimeStart #sCnt2
   GoSub UpdateStatusWindow MakeShovel

   FindItem %TinkerType C_ , %BackpackId
   Wait 5
   If #FindKind <> -1 && #FindCnt = 1
   {
      If %UOATinkerToolKey <> N/A
      {
         Key %UOATinkerToolKey %UOATinkerToolMod
         Wait %UOATinkerToolWait
      }
      If %UOATinkerToolKey = N/A
      {
         GoSub BringUpTinkerMenu #FindId
         Wait 10
         GoSub ClickTinkerButton 30 130
         If %return
            GoSub ClickTinkerButton 230 130
         Set %LastMadeWasShovel #false
      }
   }
   FindItem %TinkerType C_ , %BackpackId
   If #FindKind <> -1
   {
      If %UOAShovelKey <> N/A
      {
         Key %UOAShovelKey %UOAShovelMod
         Wait %UOAShovelWait
      }
      If %UOAShovelKey = N/A
      {
         GoSub BringUpTinkerMenu #FindId
         If %LastMadeWasShovel  ; If the last thing we made was a shovel, its easy!
            GoSub ClickTinkerButton 270 450
         If ! %LastMadeWasShovel
         {
            GoSub ClickTinkerButton 30 130
            If %Return
            {
               GoSub ClickTinkerButtonNext
               GoSub ClickTinkerButton 230 70
            }
         }
         If %return
         {
            Set %LastMadeWasShovel #true
            If %MakeTwoShovels
               GoSub ClickTinkerButton 270 450
         }
      }
      Set %_msCancelX #ContPosX + 130
      Set %_msCancelY #ContPosY + 450
      Click %_msCancelX %_msCancelY R ; Close tinker menu
   }
   GoSub RecordTiming %_msTimeStart MakeShovel
Return

; ** ClickTinkerButton **
Sub ClickTinkerButton
   Set %_ctbX %1 + #ContPosX
   Set %_ctbY %2 + #ContPosY
   Click %_ctbX %_ctbY
   Gosub waitForSysVar contSize <> 530_497 30             ;;;;;;  Modified form 530_507
   Gosub waitForSysVar contSize = 530_497 30             ;;;;;;  Modified form 530_507
   Wait 5
Return

; ** ClickTinkerButtonNoWait **
Sub ClickTinkerButtonNext
   Set %_ctbnX 380 + #ContPosX
   Set %_ctbnY 270 + #ContPosY
   Click %_ctbnX %_ctbnY F
   Wait 2s
Return

; ** BringUpTinkerMenu **
; Lag resistant opening of tinker menu
; Parameter 1: ID of tinker tool
Sub BringUpTinkerMenu
   Set %_butmTinkerTool %1
   Wait 5 ; A lot of times the tinker tool usage get 'You must wait...'
   _butmTinkerMenu:
      GoSub UseObject %_butmTinkerTool #false #false
      Gosub waitForSysVar contSize = 530_497 30         ;;;;;;  Modified form 530_507
      if ! %return
         goto _butmTinkerMenu
Return

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: Help with Tinkering section of a script please
« Reply #5 on: June 29, 2015, 01:30:21 PM »
0
In case what I posted didn't work? Probably a good idea :P
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 CushTopic starter

  • Sr. Member
  • *
  • Posts: 281
  • Activity:
    0%
  • Reputation Power: 4
  • Cush has no influence.
  • Respect: +42
  • Referrals: 0
    • View Profile
Re: Help with Tinkering section of a script please
« Reply #6 on: June 30, 2015, 06:39:23 AM »
0
Thanks for the help. I am testing these now.

Ghost what did you tweak on yours. I am always trying to learn this stuff so that I don't have to keep bugging you all.....

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: Help with Tinkering section of a script please
« Reply #7 on: June 30, 2015, 08:37:41 AM »
0
Those mod was done  way back when UO change the crafting menu.  Lot of the old script  ( pre 2010)  have lot of problem with menu size and buttom location.   I had a list of those old size so it easy to see them now.   

 Next time if you have issue during crafting, first look at the  window size and second to I click at the right location.   Those 2 steps help me lot.   Sometime is  not ovious the one that need to be mod, so I turn over for help.   Glad I can help.

Offline CushTopic starter

  • Sr. Member
  • *
  • Posts: 281
  • Activity:
    0%
  • Reputation Power: 4
  • Cush has no influence.
  • Respect: +42
  • Referrals: 0
    • View Profile
Re: Help with Tinkering section of a script please
« Reply #8 on: July 01, 2015, 08:52:45 AM »
0
Everything is running great now!

Thanks!

Ok so check the old window size and where the click is targeted then compare it to the new window size and where it should be clicking ...

Tags: