Author Topic: LV PLANT AND HARVEST (OCR TEST PROGGIE)  (Read 5947 times)

0 Members and 1 Guest are viewing this topic.

Offline LVTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Activity:
    0%
  • Reputation Power: 1
  • LV has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
LV PLANT AND HARVEST (OCR TEST PROGGIE)
« on: May 31, 2012, 04:55:37 PM »
0
I wrote this quick script yesterday to test some OCR stuff, and ended up taking it farther than planned to a working script that harvests full plants from raised flower beds (seeds and petals), then replants if wanted.  I thought with the raised flower beds it would be a lot less tedious tending plants, however, it was still not enough so this takes care of the rest.

I could add in a secure, and movement and weight checks and I plan to eventually, but this works as is for now.  Let me know of any problems if you use it.

Shows how to use OCR to scan real world coordinates using yourself as a reference as well.

Let me know of any issues.

Code: [Select]
;LV PLANT AND HARVEST (OCR TEST PROGGIE) ****************************************************************
;
;MAY 30, 2012
; I wrote this to test some OCR menu handling ideas for a huge fish quest script i have almost completed.
;
; Wait for gump is a variation of one found on scriptuo.com
;
;REQUIREMENTS :
; A:  USES RAISED FLOWER BEDS ONLY - LARGE 9 TILE ONE
; B:  USES PAMPAS OR POPPIE SEEDS ONLY
; C:  USES OCR SO NOTHING CAN BLOCK THE PLANT TILES - YOURSELF INCLUDED
; D:  USES OCR SO MAKE SURE BRIGTSIGHT OR NIGHTSIGHT IS IN USE
; E:  USES OCR SO MAKE SURE FULL SCREEN (TOP LEFT IS 0,0)
; F:  USES OCR SO THE %mbEmptyPot , %mbHarv, and %mb88 values (OCR CHECK VALUE) MIGHT be different depending on your color mode.
; G:  ANYTHING I FORGOT
; Script will harvest all poppies/pampas seeds and leaves in range (5 tiles) , will put plant to deco mode,
; and will then use clippers on it.
; The doplanting routine shows a way to scan world coord using ocr.
; Let me know if anything is wrong.
;****************************************************************************************************************
set %mbHarv 135924 ;is plant button to go to next screen
set %mb88 213219 ;is 8/8 so ready to harvest
set %mbEmptyPot 68067 , _ , 63962 , _ , 70141 , _ , 68085 , _ , 63962 , _ , 63935 , _ , 68083 , _ , 70132 , _ , 66019 ;each ocr of the plant beds is diff unfortunately
set %tPosAdj 48 ; nomatter what easyuo says, this value seems constant.
set %ClipperTypes JFF
set %DecoPlantTypes YVE ;BACKPK
set %SeedTypes PDF
set %FullPotTypes YVE ;GRND
set %EmptyPotTypes OOCB_APCB_NOCB_MOCB_XOCB_LOCB_SOCB_YOCB_ROCB
set %ReplantSeeds #True
set %WaitForGumpDefaultTimeout 50 ;run forrest, run.
set %WaitForGumpMinimumDelay 100 ;if gumps appear before game will let you click, the waitforgump had issues.  this makes it wait a minimum.
set %debug #FALSE ; set to true to help redo OCR compare values.  brain required.
;****************************************************************************************************************
goto ManageHarvest
halt
;****************************************************************************************************************

Sub ManageHarvest
ManageHarvest:
 
  set %tSkipPlanting #False
  set %ManageHarvestTLoop #True
 
  While %ManageHarvestTLoop #True
  {
    gosub DoHarvest
    If #Result = #False
    {
      set %ManageHarvestTLoop #False
    }
    gosub DoClipping
    if %ReplantSeeds = #True
    {
      gosub DoPlanting
      set %tSkipPlanting #True
    }
  }
  if %ReplantSeeds = #True && %tSkipPlanting = #false
  {
    gosub DoPlanting
  }
  halt
 
Return

;****************************************************************************************************************

Sub DoClipping
 
  set %DoClippingTLoop #True
  While %DoClippingTLoop #True
  {
    finditem %ClipperTypes C_ , #backpackid
   
    if #findcnt < 1
    {
      set %DoClippingTLoop #False
    }
    else
    {
      set %tClipID #findid
     
      finditem %DecoPlantTypes C_ , #backpackid
      if #findcnt < 1
      {
        set %DoClippingTLoop #False
      }
      else
      {
        event property #findid
        if Poppies in #property = #True || Pampas in #property = #True
        {
          set %tPlantID #findid
         
          set #lobjectid %tClipID
          event macro 17 0
          target 2s
         
          set #ltargetid %tPlantID
          event macro 22
          wait 20
        }
        else
        {
          ignoreitem #findid
        }
      }
    }
  }
  ignoreitem reset
 
Return

;****************************************************************************************************************

Sub DoPlanting
 
  set %tSeedID NA
  finditem %SeedTypes C_ , #backpackid
  if #findcnt < 1
  {
    Return
  }
  for %DoPlantingTLoop 1 #findcnt
  {
    if %tSeedID = NA
    {
      set #findindex %DoPlantingTLoop
      event property #findid
      if Poppies in #property = #True || Pampas in #property = #True
      {
        set %tSeedID #findid
      }
    }
  }
  if %tSeedID = NA
  {
    Return
  }
  finditem %EmptyPotTypes G_4
  if #findcnt < 1
  {
    Return
  }
  for %DoPlantingTLoop 1 #findcnt
  {
    set #findindex %DoPlantingTLoop
    set %ModX 0
    set %ModY 0
    if #charposx >= #findx
    {
      set %tMod #charposx  - #findx
      set %ModX %ModX - %tMod
      set %ModY %ModY - %tMod
    }
    else
    {
      set %tMod #findx - #charposx
      set %ModX %ModX + %tMod
      set %ModY %ModY + %tMod
    }
    if #charposy >= #findy
    {
      set %tMod #charposy - #findy
      set %ModX %ModX + %tMod
      set %ModY %ModY - %tMod
    }
    else
    {
      set %tMod #findy - #charposy
      set %ModX %ModX - %tMod
      set %ModY %ModY + %tMod
    }
    set %tStartX ( ( %ModX * 22 ) + 376 + 18 )
    set %tStartY ( ( %ModY * 22 ) + 296 - 26 )
    set %tEndX ( %tStartX + 10 )
    set %tEndY ( %tStartY + 10 )
   
    gosub OCRScanPixelsForCompare %tStartX %tStartY %tEndX %tEndY %mbEmptyPot
    if %debug = #True
    {
      display ok #findx , #spc , #findy , #spc , %tstartx , #spc , %tstarty , #spc , %tScanIDValCUR
    }
    if #Result = #True
    {
      set #lobjectid %tSeedID
      event macro 17 0
      target 4s
     
      set #ltargetid #findid
      wait 20
      event macro 22 0
      wait 20
    }
  }
 
Return

;****************************************************************************************************************

Sub DoHarvest
 
  finditem %FullPotTypes G_4
 
  if #findcnt < 1
  {
    Return #False
  }
 
  set #lobjectid #findid
  event macro 17 0
 
  Gosub WaitForGump contSize = 263_231 60
  if #Result = #False
  {
    display ok Timed out waiting on menu.  Please Restart.
    halt
  }
 
  set %tStartX ( %tPosAdj + #contposx + 25 )
  set %tEndX ( %tStartX + 15 )
  set %tStartY ( %tPosAdj + #contposY + 25 )
  set %tEndY ( %tStartY + 15 )
  gosub OCRScanPixelsForCompare %tStartX %tStartY %tEndX %tEndY %mbHarv
  If #Result = #True
  {
    click %tStartX %tStartY
    Gosub WaitForGump contSize = 255_231 60
    if #Result = #False
    {
      display ok Timed out waiting on menu.  Please Restart.
      halt
    }
  }
  else
  {
    display ok If you are seeing this, make sure night sight active, and nothing is covering the plants or menu gumps.  If not the problem, you might have to redo the check values as per instructions.
    halt
  }
  set %tStartX ( %tPosAdj + #contposx + 150 )
  set %tEndX ( %tStartX + 25 )
  set %tStartY ( %tPosAdj + #contposY + 65 )
  set %tEndY ( %tStartY + 15 )
  gosub OCRScanPixelsForCompare %tStartX %tStartY %tEndX %tEndY %mb88
  If #Result = #False
  {
    ignoreitem #findid
    click %tStartX %tStartY r
    Return #True
  }
  for %i 1 8 ; seeds
  {
    set %tStartX ( %tPosAdj + #contposx + 170 )
    set %tStartY ( %tPosAdj + #contposY + 120 )
    click %tStartX %tStartY
    Gosub WaitForGump contSize = 255_231 60
    if #Result = #False
    {
      display ok Timed out waiting on menu.  Please Restart.
      halt
    }
  }
  for %i 1 8 ; petals
  {
    set %tStartX ( %tPosAdj + #contposx + 100 )
    set %tStartY ( %tPosAdj + #contposY + 120 )
    click %tStartX %tStartY
    Gosub WaitForGump contSize = 255_231 60
    if #Result = #False
    {
      display ok Timed out waiting on menu.  Please Restart.
      halt
    }
  }
  ;go to dec mode screen
  set %tStartX ( %tPosAdj + #contposx + 170 )
  set %tStartY ( %tPosAdj + #contposY + 25 )
  click %tStartX %tStartY
  Gosub WaitForGump contSize = 271_231 60
  if #Result = #False
  {
    display ok Timed out waiting on menu.  Please Restart.
    halt
  }
  ;clicky yes
  set %tStartX ( %tPosAdj + #contposx + 135 )
  set %tStartY ( %tPosAdj + #contposY + 100 )
  click %tStartX %tStartY
  wait 20
 
Return #True

;****************************************************************************************************************

Sub OCRScanPixelsForCompare
 
  set #lpc 10000
 
  set %tStartScanX %1
  set %tStartScanY %2
  set %tEndScanX %3
  set %tEndScanY %4
  if %5 <> DIS
  {
    set %tScanIDValCMP %5
  }
 
  set %tScanIDValCUR 0
  set %tCurScanX %tStartScanX
  set %tCurScanY %tStartScanY
 
  set %tLoop #True
  while %tLoop = #True
  {
    savepix %tCurScanX %tCurScanY 1
    if #PIXCOL > 9999
    {
      str left #PIXCOL 2
      set %tPixHash #StrRes
      str right #PIXCOL 2
      set %tPixHash %tPixHash , #StrRes
    }
    else
    {
      set %tPixHash #PIXCOL
    }
    set %tScanIDValCUR ( %tScanIDValCUR + %tPixHash )
    set %tCurScanX ( %tCurScanX + 3 )
    if %tCurScanX > %tEndScanX
    {
      set %tCurScanX %tStartScanX
      set %tCurScanY ( %tCurScanY + 3 )
    }
    if %tCurScanY > %tEndScanY
    {
      set %tLoop #False
    }
  }
 
  if %tScanIDValCUR in %tScanIDValCMP = #True && %5 <> DIS
  {
    Return #True
  }
 
  if %5 = DIS
  {
    display ok %tScanIDValCUR
  }
 
  set #lpc 10
 
Return #False

;****************************************************************************************************************
sub WaitForGump
 
  if %0 < 4 || %4 = N/A
  {
    set %4 %WaitForGumpDefaultTimeout
  }
  if %0 < 5
  {
    set %5 return
  }
  set %4 #sCnt2 + %4
  set %tWaitForGumpTimer #systime + %WaitForGumpMinimumDelay
  wait 5
  set %tWaitForGump #True
  while %tWaitForGump = #True
  {
    set % . %5 # . %1 %2 %3
    if ! % . %5 && #sCnt2 < %4
    {
      Wait 1
    }
    else
    {
      set %tWaitForGump #False
    }
  }
  while %tWaitForGumpTimer > #systime
  {
    wait 1
  }
 
return

There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
LV PLANT AND HARVEST (OCR TEST PROGGIE) .txt
« Last Edit: May 31, 2012, 05:27:04 PM by LV »

Offline Masscre

  • Gran Master Jester !!
  • Scripthack
  • *
  • Posts: 4615
  • Activity:
    0%
  • Reputation Power: 55
  • Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!
  • Gender: Male
  • Air Guitar Commander !!
  • Respect: +144
  • Referrals: 1
    • View Profile
Re: LV PLANT AND HARVEST (OCR TEST PROGGIE)
« Reply #1 on: May 31, 2012, 05:10:43 PM »
0
There is no code listed to utilize?

Offline LVTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Activity:
    0%
  • Reputation Power: 1
  • LV has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: LV PLANT AND HARVEST (OCR TEST PROGGIE)
« Reply #2 on: May 31, 2012, 05:28:03 PM »
0
Woops.  Fixed.  At least I know people are watching :)

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: LV PLANT AND HARVEST (OCR TEST PROGGIE)
« Reply #3 on: October 08, 2013, 08:10:03 AM »
0
I tried running this but as far as i could tell nothing happened.   Perhaps a menu might help, or some visual indication.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: LV PLANT AND HARVEST (OCR TEST PROGGIE)
« Reply #4 on: April 07, 2015, 10:36:17 AM »
0
Moved to inactive submissions
When/if you return to UO and Scriptuo and would like to continue on this script pm a mod to get it moved back to script submissions.
Thank you for your submission

« Last Edit: April 07, 2015, 10:40:07 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."