The Wiki for Tale 5 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

User:Anka/Macros/Veggies

From ATITD5
< User:Anka‎ | Macros
Revision as of 01:50, 15 November 2010 by Anka (talk | contribs) (Created page with "<pre> //Veggie Macro // //This macro will plant Cabbage, Carrots, Garlic, Leeks, and Onions. This was my private //macro in Tale 3 mainly due to no other macro growing cabbage ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
//Veggie Macro
//
//This macro will plant Cabbage, Carrots, Garlic, Leeks,  and Onions.  This was my private
//macro in Tale 3 mainly due to no other macro growing cabbage at the time. Supply and demand :)
//
//The basic flow and code is the same but I've made some improvements in this rewrite.  This
//macro no longer relies on color.  Color was different with each type of video card which
//caused many problems for some.  Due to the large rewrite, I have not been able to test this
//macro fully.  You may still find problems.  Pass them on to me please.
//
//The BIGGEST ISSUE with veggies is that initial plant location changes each time you move.
//If you find that the macro is missing the plants, take a step in a direction to change
//the initial plant location and try again.  You may have to do this a few times until you
//find the right spot.  This is the part of the macro that I have not fully tested.  You can
//also try a different resolution as mouse locations are different in each resolution.
//
//SETUP
//Resolution 1024 x 768, 1280 x 1024, 1360 x 768 or 1920 x 1080
//Cartographer camera zoomed all the way in
//Face East if you have a problem with macro hitting your hands.
//Have at least 5 seeds and 20 jugs, more for onions if planting over 4
//Be close enough to water to see your water icon
//Regular sized action icons
//Pin your plant window in the top left corner
//
//When growing leeks, make sure the mouse is hitting the top right leaf.  If this does not
//happen, all other plants will be off.  Follow the steps above about initial plant location
//to fix this.

//  Enjoy :)     Written with ACTool 4.6.2 by Anka   :Updated with 5.4.0

Constants
  Loops = 0
  Water = 5
  Num = 4
  NewX = 0
  NewY = 0
  TopX = 0
  TopY = 0
  RightX = 0
  RightY = 0
  LeftX = 0
  LeftY = 0
  TempX = 0
  TempY = 0
  Done = 0
  varOriginalMouseX = 0
  varOriginalMouseY = 0
  ResetX = 607
  ResetY = 392
  //Cabbage
  CabSX = 32
  CabSY = 58
  CabTopAdd = 4
  CabBXSM = 41
  CabBYSM = 1
  CabCXSM = 57
  CabCYSM = 104
  CabDXSM = 29
  CabDYSM = 86
  CabAXadj = 6
  CabAYadj = 15
  CabBXadj = 6
  CabBYadj = 15
  CabCXadj = 6
  CabCYadj = 13
  CabDXadj = 15
  CabDYadj = 5
  CabX = 0
  CabY = 0
  CabBX = 474
  CabBY = 330
  CabCX = 470
  CabCY = 424
  CabDX = 557
  CabDY = 407
  CabAX = 544
  CabAY = 326
  CabA = 0
  CabB = 0
  CabC = 0
  CabD = 0
  //Garlic
  GarSX = 46
  GarSY = 58
  GarAYSM = 3
  GarBXSM = 41
  GarCXSM = 39
  GarCYSM = 69
  GarDXSM = 9
  GarDYSM = 70
  GarAXadj = 1
  GarAYadj = 8
  GarBXadj = 1
  GarBYadj = 8
  GarCXadj = 1
  GarCYadj = 10
  GarDXadj = 1
  GarDYadj = 10
  GarAX = 548
  GarAY = 335
  GarBX = 0
  GarBY = 0
  GarCX = 0
  GarCY = 0
  GarDX = 0
  GarDY = 0
  GarA = 0
  GarB = 0
  GarC = 0
  GarD = 0
  //Leeks
  LeekSX = 39
  LeekSY = 35
  LeekBXSM = 41
  LeekCXSM = 57
  LeekCYSM = 80
  LeekDXSM = 6
  LeekDYSM = 74
  LeekAXadj = 3
  LeekAYadj = 13
  LeekBXadj = 3
  LeekBYadj = 13
  LeekCXadj = 6
  LeekCYadj = 11
  LeekDXadj = 7
  LeekDYadj = 5
  LeekA = 0
  LeekB = 0
  LeekC = 0
  LeekD = 0
  LeekAX = 0
  LeekAY = 0
  LeekBX = 0
  LeekBY = 0
  LeekCX = 0
  LeekCY = 0
  LeekDX = 0
  LeekDY = 0
  //Carrots
  CarSX = 25
  CarSY = 42
  CarAYSM = 1
  CarBXSM = 41
  CarCXSM = 45
  CarCYSM = 62
  CarDXSM = 13
  CarDYSM = 57
  CarAXadj = 3
  CarAYadj = 5
  CarBXadj = 3
  CarBYadj = 5
  CarCXadj = 6
  CarCYadj = 6
  CarDXadj = 5
  CarDYadj = 2
  CarA = 0
  CarB = 0
  CarC = 0
  CarD = 0
  CarAX = 523
  CarAY = 348
  CarBX = 0
  CarBY = 0
  CarCX = 0
  CarCY = 0
  CarDX = 0
  CarDY = 0
  //Onions
  Ox = 495
  Oy = 380
  OStep = 41
  ODragX = 4
  ODragY = 90
  OWX = 50
  OWY = 120
  MoveLeft = 35, 96
  MoveRight = 82, 96
  MoveUP = 59, 74
  MoveDown = 59, 120
  Build = 30, 155
  Size = 0
  Onion = 1
  WaterX = 0
  WaterY = 0
  CenterX = 0
  CenterY = 0
  Direction = 0  // 0 = Icons on left, 1 = Icons on right
  Count = 0
  Button = 0
  Red = 31
  Green = 209
  Blue = 211
  SubX = 31
  Color = 200
  //New Constants, clean later
  //Onions
  Plants = 0
  P1Delay = 0
  MoveDelay = 0
  WDelay = 0
  MDelay = 100
  SDelay = 500
  FO = 0
  FPX = 0
  FPY = 0
  Close = 0
  OPinX = 170
  OPinY = 88
  PinX = 170
  PinY = 28
  Sow = 50, 40
  Res = 0
End

Object Water
  222=0,0|229=0,2|225=0,4|219=0,6|225=0,8|236=0,10
  206=2,0|191=2,2|220=2,4|223=2,6|224=2,8|250=2,10
  215=4,0|221=4,2|217=4,4|206=4,6|235=4,8|253=4,10
  191=6,0|211=6,2|222=6,4|238=6,6|245=6,8|249=6,10
  217=8,0|233=8,2|214=8,4|213=8,6|230=8,8|250=8,10
  224=10,0|217=10,2|222=10,4|229=10,6|232=10,8|248=10,10
End

Object Plant //1920x1080
  148=2,0|148=2,2|148=2,4|148=2,6|148=2,8
End

Form Veggie, Settings
  ed1=Combobox:Veggie:Cabbage, Carrots, Garlic, Leeks, Onions
  ed2=Editbox:Batch:1
  ed3=Checkbox:Right Action Buttons?:False
  ed4=Combobox:Resolution:1024x768, 1280x1024, 1360x768, 1920x1080
end

FormLoad Veggie, Veggie.frm

if ShowForm Veggie
  Set Loops = Veggie[ed2]
  If Veggie[ed3] = False
    SetConst Direction = 0
  Else
    SetConst Direction = 1
  End
  Set Res = Veggie[ed4]
else
  stop
end

FormSave Veggie, Veggie.frm
//
Case
When Veggie[ed1] = Onions
  Form Onions, Onions
    ed1=Editbox:Batch:1
    ed2=Combobox:# of Plants:1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
    ed3=Editbox:Plant 1 wait time:1300
    ed4=Editbox:Move wait time:900
    ed5=Editbox:Time between Waterings:800
  end
  
  FormLoad Onions, Onions.frm
  
  if ShowForm Onions
    Set Loops = Onions[ed1]
    Set Plants = Onions[ed2]
    Set P1Delay = Onions[ed3]
    Set MoveDelay = Onions[ed4]
    Set WDelay = Onions[ed5]
  Else
    stop
  end
  
  FormSave Onions, Onions.frm
End

KeyDown @{Tab} 200
Delay 2000

Compute CenterX = {Screenwidth} / 2
Compute CenterY = {ScreenHeight} / 2

Call Resolution
call Findbutton
call water
Call Veggie[ed1]

Procedure Leeks             //---------------Leeks----------------//
  Loop $Loops
    //A
    Call Sow
    Call MoveRight
    Call MoveUP
    Delay $MDelay
    Compute LeekAX = $CenterX + $LeekSX
    Compute LeekAY = $CenterY - $LeekSY
    While $Size = 0
      MousePos $LeekAX, $LeekAY
      Delay $MDelay
      RightClick
      Delay $MDelay
      IsObject Plant at {MouseX}, {MouseY}
        Set TopX = {mousex}
        Keys {ESC}
        Delay $MDelay
        Compute TopY = {mousey} + 2
        MousePos $TopX, $TopY
        Delay $MDelay
        Call FindLeft
        Set Done = 0
        Call FindRight
        Set Done = 0
        Compute Result = $RightX - ($RightX - $LeftX)/2
        Formatnumber TopX = $Result, ###
        Call FindTop
        Set Size = 1
      Else
        Compute LeekAY = $LeekAY + 1
        Compute LeekAX = $LeekAX - 1
      End
    End
    Set LeekAX = $TopX
    Set LeekAY = $TopY
    Compute LeekBX = $LeekAX - $LeekBXSM
    Compute LeekBY = $LeekAY + 1
    Compute LeekCX = $LeekAX - $LeekCXSM
    Compute LeekCY = $LeekAY + $LeekCYSM
    Compute LeekDX = $LeekAX + $LeekDXSM
    Compute LeekDY = $LeekAY + $LeekDYSM
    Timestamp $TopX, $TopY
    
    Call Build
    
    //B
    Call Sow
    Call MoveLeft
    Call MoveUP
    Call Build
    
    //C
    Call Sow
    Call MoveLeft
    Call MoveDown
    Call Build
    
    //D
    Call Sow
    Call MoveRight
    Call MoveDown
    Call Build

    While $LeekA < 5 or $LeekB < 5 or $LeekC < 5 or $LeekD < 5
      If $LeekA < 5
        MousePos $LeekAX, $LeekAY
        Delay $MDelay
        Call CheckA
      End
      Delay 50
      If $LeekB < 5
        MousePos $LeekBX, $LeekBY
        Delay $MDelay
        Call CheckB
      End
      Delay 50
      If $LeekC < 5
        MousePos $LeekCX, $LeekCY
        Delay $MDelay
        Call CheckC
      End
      Delay 50
      If $LeekD < 5
        MousePos $LeekDX, $LeekDY
        Delay $MDelay
        Call CheckD
      End
      Delay 1000
    End
    
    SetConst LeekA = 0
    SetConst LeekB = 0
    SetConst LeekC = 0
    SetConst LeekD = 0
    SetConst Size = 0
    Call Water
  End
End

Procedure Garlic          //--------------Garlic-----------------//
  Loop $Loops
    //A
    Call Sow
    Call MoveRight
    Call MoveUP

    Compute GarAX = $CenterX + $GarSX
    Compute GarAY = $CenterY - $GarSY
    While $Size = 0
      MousePos $GarAX, $GarAY
      Delay $MDelay
      Rightclick
      Delay $MDelay
      IsObject Plant at {MouseX}, {MouseY}
        Set TopX = {mousex}
        Keys {ESC}
        Delay $MDelay
        Compute TopY = {mousey} + 2
        MousePos $TopX, $TopY
        Delay $MDelay
        Call FindLeft
        Set Done = 0
        Call FindRight
        Set Done = 0
        Compute Result = $RightX - ($RightX - $LeftX)/2
        Formatnumber TopX = $Result, ###
        Call FindTop
        Set Size = 1
      Else
        Compute GarAX = $GarAX - 1
        Compute GarAY = $GarAY + 1
      End
    End
    Compute GarAX = $TopX
    Compute GarAY = $TopY
    MousePos $GarAX, $GarAY
    Delay $MDelay
    Compute GarAY = $TopY + $GarAYSM
    Compute GarBX = $TopX - $GarBXSM
    Compute GarBY = $GarAY
    Compute GarCX = $TopX - $GarCXSM
    Compute GarCY = $TopY + $GarCYSM
    Compute GarDX = $TopX + $GarDXSM
    Compute GarDY = $TopY + $GarDYSM
    Timestamp $TopX, $TopY
    
    Call Build
    
    //B
    Call Sow
    Call MoveLeft
    Call MoveUp
    Call Build
    
    //C
    Call Sow
    Call MoveLeft
    Call MoveDown
    Call Build
    
    //D
    Call Sow
    Call MoveRight
    Call MoveDown
    Call Build

    While $GarA < 5 or $GarB < 5 or $GarC < 5 or $GarD < 5
      If $GarA < 5
        MousePos $GarAX, $GarAY
        Delay $MDelay
        Call CheckA
      End
      Delay 150
      If $GarB < 5
        MousePos $GarBX, $GarBY
        Delay $MDelay
        Call CheckB
      End
      Delay 150
      If $GarC < 5
        MousePos $GarCX, $GarCY
        Delay $MDelay
        Call CheckC
      End
      Delay 150
      If $GarD < 5
        MousePos $GarDX, $GarDY
        Delay $MDelay
        Call CheckD
      End
    End
    
    Call Water
    Delay 5000
    SetConst GarAX = 0
    SetConst GarAY = 0
    SetConst GarA = 0
    SetConst GarB = 0
    SetConst GarC = 0
    SetConst GarD = 0
  End
End

Procedure Cabbage   //-----------------CABBAGE------------------//
  Loop $Loops
    //A
    Call Sow
    Call MoveRight
    Call MoveUP
    
    Compute CabAX = $CenterX + $CabSX
    Compute CabAY = $CenterY - $CabSY
    While $Size = 0
      MousePos $CabAX, $CabAY
      Delay $Mdelay
      RightClick
      Delay $MDelay
      IsObject Plant at {MouseX}, {MouseY}
        Set TopX = {mousex}
        Keys {ESC}
        Delay $MDelay
        Compute TopY = {mousey} + $CabTopAdd
        MousePos $TopX, $TopY
        Delay $MDelay
        Call FindLeft
        Set Done = 0
        Call FindRight
        Set Done = 0
        Compute Result = $RightX - ($RightX - $LeftX)/2
        Formatnumber TopX = $Result, ###
        Call FindTop
        Set Size = 1
      Else
        Compute CabAX = $CabAX - 1
        Compute CabAY = $CabAY + 1
      End
    End
    Timestamp $TopX, $TopY
    
    Compute CabAX = $TopX
    Compute CabAY = $TopY
    Compute CabBX = $CabAX - $CabBXSM
    Compute CabBY = $CabAY + $CabBYSM
    Compute CabCX = $CabAX - $CabCXSM
    Compute CabCY = $CabAY + $CabCYSM
    Compute CabDX = $CabAX + $CabDXSM
    Compute CabDY = $CabAY + $CabDYSM
    
    Call Build
    
    //B
    Call Sow
    Call MoveLeft
    Call MoveUP
    Call Build
    
    //C
    Call Sow
    Call MoveLeft
    Call MoveDown
    Call Build
    
    //D
    Call Sow
    Call MoveRight
    Call MoveDown
    Call Build
    
    While $CabA < 5 or $CabB < 5 or $CabC < 5 or $CabD < 5
      If $CabA < 5
        MousePos $CabAX, $CabAY
        Delay $MDelay
        Call CheckA
      End
      If $CabB < 5
        MousePos $CabBX, $CabBY
        Delay $MDelay
        Call CheckB
      End
      If $CabC < 5
        MousePos $CabCX, $CabCY
        Delay $MDelay
        Call CheckC
      End
      If $CabD < 5
        MousePos $CabDX, $CabDY
        Delay $MDelay
        Call CheckD
      End
    End
    If {loopno} <> $Loops
      Call Water
    End
    Delay 5000
    SetConst CabAX = 0
    SetConst CabAY = 0
    SetConst CabA = 0
    SetConst CabB = 0
    SetConst CabC = 0
    SetConst CabD = 0
  End
End

Procedure CheckA
  setconst varOriginalMouseX = {mousex}
  setconst varOriginalMouseY = {mousey}
  RightClick
  Delay 500
  IsObject Plant at {MouseX}, {MouseY}
    Compute NewX = {mousex} + 25
    Compute NewY = {mousey} + 7
    MousePos $NewX, $NewY
    Delay $MDelay
    Rightclick
    Compute CabA = $CabA + 1
    Compute GarA = $GarA + 1
    Compute LeekA = $LeekA + 1
    Compute CarA = $CarA + 1
    Compute CabAX = $varOriginalMouseX + $CabAXadj
    Compute GarAX = $varOriginalMouseX - $GarAXadj
    Compute LeekAX = $varOriginalMouseX + $LeekAXadj
    Compute CabAY = $varOriginalMouseY - $CabAYadj
    Compute GarAY = $varOriginalMouseY - $GarAYadj
    Compute LeekAY = $varOriginalMouseY - $LeekAYadj
    Compute CarAX = $varOriginalMouseX - $CarAXadj
    Compute CarAY = $varOriginalMouseY - $CarAYadj
  End
End

Procedure CheckB
  setconst varOriginalMouseX = {mousex}
  setconst varOriginalMouseY = {mousey}
  RightClick
  Delay 500
  IsObject Plant at {MouseX}, {MouseY}
    Compute NewX = {mousex} + 25
    Compute NewY = {mousey} + 7
    MousePos $NewX, $NewY
    Delay 250
    Rightclick
    Compute CabB = $CabB + 1
    Compute GarB = $GarB + 1
    Compute LeekB = $LeekB + 1
    Compute CarB = $CarB + 1
    Compute CabBX = $varOriginalMouseX - $CabBXadj
    Compute GarBX = $varOriginalMouseX - $GarBXadj
    Compute LeekBX = $varOriginalMouseX + $LeekBXadj
    Compute CabBY = $varOriginalMouseY - $CabBYadj
    Compute GarBY = $varOriginalMouseY - $GarBYadj
    Compute LeekBY = $varOriginalMouseY - $LeekBYadj
    Compute CarBX = $varOriginalMouseX - $CarBXadj
    Compute CarBY = $varOriginalMouseY - $CarBYadj
  End
End

Procedure CheckC
  setconst varOriginalMouseX = {mousex}
  setconst varOriginalMouseY = {mousey}
  RightClick
  Delay 500
  IsObject Plant at {mousex}, {MouseY}
    Compute NewX = {mousex} + 25
    Compute NewY = {mousey} + 7
    MousePos $NewX, $NewY
    Delay 250
    Rightclick
    Compute CabC = $CabC + 1
    Compute GarC = $GarC + 1
    Compute LeekC = $LeekC + 1
    Compute CarC = $CarC + 1
    Compute CabCX = $varOriginalMouseX - $CabCXadj
    Compute GarCX = $varOriginalMouseX - $GarCXadj
    Compute LeekCX = $varOriginalMouseX - $LeekCXadj
    Compute CabCY = $varOriginalMouseY + $CabCYadj
    Compute GarCY = $varOriginalMouseY + $GarCYadj
    Compute LeekCY = $varOriginalMouseY + $LeekCYadj
    Compute CarCX = $varOriginalMouseX - $CarCXadj
    Compute CarCY = $varOriginalMouseY + $CarCYadj
  End
End

Procedure CheckD
  setconst varOriginalMouseX = {mousex}
  setconst varOriginalMouseY = {mousey}
  RightClick
  Delay 500
  IsObject Plant at {MouseX}, {MouseY}
    Compute NewX = {mousex} + 25
    Compute NewY = {mousey} + 7
    MousePos $NewX, $NewY
    Delay 250
    Rightclick
    Compute CabD = $CabD + 1
    Compute GarD = $GarD + 1
    Compute LeekD = $LeekD + 1
    Compute CarD = $CarD + 1
    Compute CabDX = $varOriginalMouseX + $CabDXadj
    Compute GarDX = $varOriginalMouseX - $GarDXadj
    Compute LeekDX = $varOriginalMouseX + $LeekDXadj
    Compute CabDY = $varOriginalMouseY + $CabDYadj
    Compute GarDY = $varOriginalMouseY + $GarDYadj
    Compute LeekDY = $varOriginalMouseY + $LeekDYadj
    Compute CarDX = $varOriginalMouseX + $CarDXadj
    Compute CarDY = $varOriginalMouseY + $CarDYadj
  End
End

Procedure Carrots   //----------------Carrots----------------//
  Loop $Loops
    //A
    Call Sow
    Call MoveRight
    Call MoveUP
    
    Compute CarAX = $CenterX + $CarSX
    Compute CarAY = $CenterY - $CarSY
    While $Size = 0
      MousePos $CarAX, $CarAY
      Delay $MDelay
      RightClick
      Delay $MDelay
      IsObject Plant at {MouseX}, {MouseY}
        Set TopX = {mousex}
        Compute TopY = {mousey} + 1
        Keys {Esc}
        Delay $MDelay
        MousePos $TopX, $TopY
        Delay $MDelay
        Call FindLeft
        Set Done = 0
        Call FindRight
        Compute Result = $RightX - ($RightX - $LeftX)/2
        Formatnumber TopX = $Result, ###
        MousePos $TopX, $TopY
        Delay $MDelay
        Set Done = 0
        Call FindTop
        Set Done = 0
        Call FindRight
        Set Done = 0
        Call FindLeft
        Compute Result = $RightX - ($RightX - $LeftX)/2
        Formatnumber TopX = $Result, ###
        Set Done = 0
        Call FindTop
        Set Size = 1
      Else
        Compute CarAY = $CarAY + 1
      End
    End
    
    //Set all Variables
    Compute CarAX = $TopX
    Compute CarAY = $TopY + $CarAYSM
    Compute CarBX = $TopX - $CarBXSM
    Compute CarBY = $CarAY
    Compute CarCX = $TopX - $CarCXSM
    Compute CarCY = $TopY + $CarCYSM
    Compute CarDX = $TopX + $CarDXSM
    Compute CarDY = $TopY + $CarDYSM
    TimeStamp $CarAX, $CarAY
    Call Build
    
    //B
    Call Sow
    Call MoveLeft
    Call MoveUP
    Call Build
    
    //C
    Call Sow
    Call MoveLeft
    Call MoveDown
    Call Build
    
    //D
    Call Sow
    Call MoveRight
    Call MoveDown
    Call Build
    
    While $CarA < 5 or $CarB < 5 or $CarC < 5 or $CarD < 5
      If $CarA < 5
        MousePos $CarAX, $CarAY
        Delay $MDelay
        Call CheckA
      End
      Delay 50
      If $CarB < 5
        MousePos $CarBX, $CarBY
        Delay $MDelay
        Call CheckB
      End
      Delay 50
      If $CarC < 5
        MousePos $CarCX, $CarCY
        Delay $MDelay
        Call CheckC
      End
      Delay 50
      If $CarD < 5
        MousePos $CarDX, $CarDY
        Delay $MDelay
        Call CheckD
      End
      Delay 2000
    End
    
    If {loopno} <> $Loops
      Call Water
    End
    
    Delay 5000
    SetConst CarAX = 0
    SetConst CarAY = 0
    SetConst CarA = 0
    SetConst CarB = 0
    SetConst CarC = 0
    SetConst CarD = 0
  End
  
End

//Onions
Procedure Onions
  Loop $Loops
    Call Plant

    SetConst Onion = 1

    Loop $Plants  //Find and Pin Plants
      Mousepos $Ox, $Oy
      Delay 200
      Call CheckOnions
      Compute FPX = $FPX - $OStep
    End
    SetConst Onion = 1
    Loop 5   //Watering
      Loop $Plants  // Number of plants
        If $Onion = 5
          Compute OWX = {mousex} + 168
          SetConst OWY = 120
        End
        If $Onion = 9
          Compute OWX = {mousex} + 168
          SetConst OWY = 120
        End
        
        Compute NewY = $OWY - 20
        MousePos $OWX, $NewY
        Delay 200
        Rightclick
        Delay 300
        Mousepos $OWX, $OWY
        Delay 200
        Rightclick
        If $Close = 4
          SetConst varOriginalMouseX = {MouseX}
          SetConst varOriginalMouseY = {MouseY}
          Compute NewX = $OWX + 122
          Compute NewY = $OWY - 30
          MousePos $NewX, $NewY
          Delay 200
          Rightclick
          Delay 200
          MousePos $varOriginalMouseX, $varOriginalMouseY
          Delay 200
        End
        Compute OWY = {MouseY} + 60
        If $Onion = 1
          Delay $P1Delay  //Plant 1 time
        Else
          Delay $MoveDelay  //Move Time
        End
        Compute Onion = $Onion + 1
      End
      
      If $Close <> 4
        Delay $WDelay  //Pause between waterings
      End
      Inc $Close
      SetConst Onion = 1
      Compute OWX = 50
      Compute OWY = 120
    End
    
    //Reposition

    Mousepos $ResetX, $ResetY
    Leftclick
    Delay 1000
    Compute Onion = 1
    Compute ODragX = 4
    Compute ODragY = 90
    Compute Ox = 495
    Compute Oy = 380
    Compute OWX = 50
    Compute OWY = 120
  End
End

Procedure Plant  //For Onions
  Loop $Plants  //Number of plants
    Call Sow
    Compute Num = $Onion * 2 - 1
    MousePos 37, 97
    Delay $MDelay
    Loop $Num
      Rightclick
    End
    // New Routine to find onions before plant
    If {loopno} = 1
      Mousepos $Ox, $Oy
      Delay $MDelay
      Loop 40
        RightClick
        IsObject Plant at {MouseX}, {MouseY}
          SetConst FPY = {MouseY}
          SetConst TopX = {MouseX}
          SetConst TopY = {MouseY}
          Keys {Esc}
          Delay $MDelay
          Call FindLeft
          Set Done = 0
          Call FindRight
          Set Done = 0
          Compute Result = $RightX - ($RightX - $LeftX)/2
          Formatnumber FPX = $Result, ###
          Break
        Else
          Compute Oy = $Oy + 1
          MousePos $OX, $Oy
          Delay $MDelay
        End
      End
    End
    Compute Onion = $Onion + 1
    
    Call Build
  End
End

Procedure CheckOnions
  MousePos $FPX, $FPY
  Delay 200
  Rightclick
  Compute NewX = {mousex} + 172
  Compute NewY = {mousey} - 23
  MousePos $NewX, $NewY
  Delay 200
  Leftclick
  Compute NewX = {mousex} - 169
  MousePos $NewX, $NewY
  if $Onion > 8
    Dragto $ODragX, $ODragY
    Compute ODragY = $ODragY + 60
  End
  if $Onion = 5 or $Onion = 6 or $Onion = 7 or $Onion = 8
    Dragto $ODragX, $ODragY
    Compute ODragY = $ODragY + 60
  End
  If $Onion = 2 or $Onion = 3 or $Onion = 4
    Dragto $ODragX, $ODragY
    Compute ODragY = $ODragY + 60
  End
  if $Onion = 1
    Dragto $ODragX, $ODragY
    Compute ODragY = $ODragY + 60
  End
  Compute Onion = $Onion + 1
  If $Onion = 5
    SetConst ODragY = 90
    Compute ODragX = $ODragX + 168
  End
  If $Onion = 9
    SetConst ODragY = 90
    Compute ODragX = $ODragX + 168
  END
End

Procedure FindButton  //Run Once Find Button and Set X,Y Coords
  Compute CenterX = {ScreenWidth} / 2
  Compute CenterY = {ScreenHeight} / 2
  SetConst NewX = $CenterX
  SetConst NewY = 98
  MousePos $NewX, $NewY
  Case
  When $Direction = 0 //Move Left
    SetConst Count = 50
    While $NewX > $Count
      MousePos $NewX, $NewY
      IsObject Water at {mousex}, {mousey}
        SetConst WaterX = {mousex}
        SetConst WaterY = {mousey}
        Break
      Else
        Compute NewX = $NewX - 1
      End
    End
  When $Direction = 1 //Move Right
    Compute Count = {ScreenWidth} - 50
    While $NewX < $Count
      MousePos $NewX, $NewY
      IsObject Water at {mousex}, {mousey}
        SetConst WaterX = {mousex}
        SetConst WaterY = {mousey}
        Break
      Else
        Compute NewX = $NewX + 1
      End
    End
  End
End

Procedure Water
  MousePos $WaterX, $WaterY
  Delay $MDelay
  Rightclick
  Delay $MDelay
  Compute NewX = {screenwidth} / 2
  Compute NewY = {screenheight} / 2
  Compute NewY = $NewY + 35
  MousePos $NewX, $NewY
  Delay $MDelay
  Rightclick
  Delay 3000
End

Procedure FindLeft
  While $Done = 0
    Compute TopX = $TopX - 1
    MousePos $TopX, $TopY
    Delay $MDelay
    Rightclick
    Delay $MDelay
    IsObject Plant at {MouseX}, {MouseY}
      Set LeftX = {mousex}
      Keys {Esc}
      Delay $MDelay
    Else
      Compute TopX = $TopX + 1
      Compute LeftX = $TopX
      inc Done
    End
  End
End

Procedure FindRight
  While $Done = 0
    Compute TopX = $TopX + 1
    MousePos $TopX, $TopY
    Delay $MDelay
    Rightclick
    Delay $MDelay
    IsObject Plant at {MouseX}, {MouseY}
      Set RightX = {MouseX}
      Keys {Esc}
      Delay $MDelay
    Else
      Compute TopX = $TopX - 2
      MousePos $TopX, $TopY
      inc Done
    End
  End
End

Procedure FindTop
  While $Done = 0
    Compute TopY = $TopY - 1
    MousePos $TopX, $TopY
    Delay $MDelay
    Rightclick
    Delay $MDelay
    IsObject Plant at {MouseX}, {MouseY}
      Set TopY = {MouseY}
      Keys {Esc}
      Delay $MDelay
    else
      inc Done
      Compute TopY = $TopY + 1
    End
  End
End

Procedure Sow
  MousePos $Sow
  Delay $MDelay
  Rightclick
End

Procedure MoveRight
  MousePos $MoveRight
  Delay $MDelay
  RightClick
End

Procedure MoveUP
  MousePos $MoveUp
  Delay $MDelay
  RightClick
End

Procedure MoveLeft
  MousePos $MoveLeft
  Delay $MDelay
  RightClick
End

Procedure MoveDown
  MousePos $MoveDown
  Delay $MDelay
  RightClick
End

Procedure Build
  MousePos $Build
  Delay $MDelay
  RightClick
End

Procedure Resolution
  Case
  When $Res = 1920x1080
    //Cabbage
    SetConst CabSX = 65
    SetConst CabSY = 116
    SetConst CabBXSM = 77
    SetConst CabBYSM = 1
    SetConst CabCXSM = 117
    SetConst CabCYSM = 181
    SetConst CabDXSM = 56
    SetConst CabDYSM = 162
    SetConst CabAXadj = 12
    SetConst CabAYadj = 23
    SetConst CabBXadj = 14
    SetConst CabBYadj = 24
    SetConst CabCXadj = 16
    SetConst CabCYadj = 23
    SetConst CabDXadj = 27
    SetConst CabDYadj = 10
    //Carrots
    SetConst CarSX = 23
    SetConst CarSY = 78
    SetConst CarAYSM = 1
    SetConst CarBXSM = 77
    SetConst CarCXSM = 88
    SetConst CarCYSM = 115
    SetConst CarDXSM = 25
    SetConst CarDYSM = 105
    SetConst CarAXadj = 8
    SetConst CarAYadj = 10
    SetConst CarBXadj = 8
    SetConst CarBYadj = 10
    SetConst CarCXadj = 8
    SetConst CarCYadj = 10
    SetConst CarDXadj = 8
    SetConst CarDYadj = 5
    //Garlic
    SetConst GarSX = 55
    SetConst GarSY = 69
    SetConst GarAYSM = 2
    SetConst GarBXSM = 79
    SetConst GarCXSM = 67
    SetConst GarCYSM = 141
    SetConst GarDXSM = 11
    SetConst GarDYSM = 143
    SetConst GarAXadj = 8
    SetConst GarAYadj = 13
    SetConst GarBXadj = 8
    SetConst GarBYadj = 13
    SetConst GarCXadj = 6
    SetConst GarCYadj = 15
    SetConst GarDXadj = 3
    SetConst GarDYadj = 18
    //Leeks
    SetConst LeekSX = 63
    SetConst LeekSY = 69
    SetConst LeekBXSM = 78
    SetConst LeekCXSM = 109
    SetConst LeekCYSM = 150
    SetConst LeekDXSM = 9
    SetConst LeekDYSM = 135
    SetConst LeekAXadj = 3
    SetConst LeekAYadj = 26
    SetConst LeekBXadj = 3
    SetConst LeekBYadj = 26
    SetConst LeekCXadj = 11
    SetConst LeekCYadj = 15
    SetConst LeekDXadj = 15
    SetConst LeekDYadj = 11
    //Onions
    SetConst Ox = 920
    SetConst Oy = 511
    SetConst ResetX = 1135
    SetConst ResetY = 556
    SetConst OStep = 77
  When $Res = 1280x1024
    //Cabbage
    SetConst CabSX = 50
    SetConst CabSY = 74
    SetConst CabBXSM = 51
    SetConst CabBYSM = 1
    SetConst CabCXSM = 78
    SetConst CabCYSM = 123
    SetConst CabDXSM = 37
    SetConst CabDYSM = 109
    SetConst CabAXadj = 8
    SetConst CabAYadj = 17
    SetConst CabBXadj = 8
    SetConst CabBYadj = 18
    SetConst CabCXadj = 10
    SetConst CabCYadj = 16
    SetConst CabDXadj = 16
    SetConst CabDYadj = 6
    //Carrots
    SetConst CarSX = 11
    SetConst CarSY = 37
    SetConst CarAYSM = 1
    SetConst CarBXSM = 52
    SetConst CarCXSM = 58
    SetConst CarCYSM = 77
    SetConst CarDXSM = 16
    SetConst CarDYSM = 69
    SetConst CarAXadj = 4
    SetConst CarAYadj = 8
    SetConst CarBXadj = 4
    SetConst CarBYadj = 8
    SetConst CarCXadj = 7
    SetConst CarCYadj = 8
    SetConst CarDXadj = 5
    SetConst CarDYadj = 4
    //Onions
    SetConst Ox = 618
    SetConst Oy = 487
    SetConst ResetX = 707
    SetConst ResetY = 531
    SetConst OStep = 52
    //Garlic
    SetConst GarSX = 36
    SetConst GarSY = 51
    SetConst GarAYSM = 1
    SetConst GarBXSM = 57
    SetConst GarCXSM = 45
    SetConst GarCYSM = 92
    SetConst GarDXSM = 8
    SetConst GarDYSM = 93
    SetConst GarAXadj = 4
    SetConst GarAYadj = 9
    SetConst GarBXadj = 4
    SetConst GarBYadj = 9
    SetConst GarCXadj = 4
    SetConst GarCYadj = 10
    SetConst GarDXadj = 2
    SetConst GarDYadj = 10
    //Leeks
    SetConst LeekSX = 43
    SetConst LeekSY = 60
    SetConst LeekBXSM = 52
    SetConst LeekCXSM = 69
    SetConst LeekCYSM = 104
    SetConst LeekDXSM = 9
    SetConst LeekDYSM = 94
    SetConst LeekAXadj = 4
    SetConst LeekAYadj = 16
    SetConst LeekBXadj = 4
    SetConst LeekBYadj = 16
    SetConst LeekCXadj = 7
    SetConst LeekCYadj = 12
    SetConst LeekDXadj = 8
    SetConst LeekDYadj = 7
  When $Res = 1360x768
    //Cabbage
    SetConst CabSX = 44
    SetConst CabSY = 68
    SetConst CabBXSM = 53
    SetConst CabBYSM = 1
    SetConst CabCXSM = 83
    SetConst CabCYSM = 129
    SetConst CabDXSM = 40
    SetConst CabDYSM  = 115
    SetConst CabAXadj = 9
    SetConst CabAYadj = 19
    SetConst CabBXadj = 9
    SetConst CabBYadj = 20
    SetConst CabCXadj = 12
    SetConst CabCYadj = 21
    SetConst CabDXadj = 15
    SetConst CabDYadj = 8
    //Carrots
    SetConst CarSX = 13
    SetConst CarSY = 46
    SetConst CarAYSM = 1
    SetConst CarBXSM = 56
    SetConst CarCXSM = 62
    SetConst CarCYSM = 82
    SetConst CarDXSM = 18
    SetConst CarDYSM = 73
    SetConst CarAXadj = 4
    SetConst CarAYadj = 8
    SetConst CarBXadj = 4
    SetConst CarBYadj = 8
    SetConst CarCXadj = 7
    SetConst CarCYadj = 8
    SetConst CarDXadj = 6
    SetConst CarDYadj = 4
    //Onions
    SetConst Ox = 657
    SetConst Oy = 386
    SetConst ResetX = 805
    SetConst ResetY = 402
    SetConst OStep = 55
    //Garlic
    SetConst GarSX = 34
    SetConst GarSY = 58
    SetConst GarAYSM = 1
    SetConst GarBXSM = 57
    SetConst GarCXSM = 45
    SetConst GarCYSM = 98
    SetConst GarDXSM = 11
    SetConst GarDYSM = 97
    SetConst GarAXadj = 5
    SetConst GarAYadj = 10
    SetConst GarBXadj = 5
    SetConst GarBYadj = 10
    SetConst GarCXadj = 3
    SetConst GarCYadj = 11
    SetConst GarDXadj = 3
    SetConst GarDYadj = 11
    //Leeks
    SetConst LeekSX = 57
    SetConst LeekSY = 64
    SetConst LeekBXSM = 56
    SetConst LeekCXSM = 76
    SetConst LeekCYSM = 109
    SetConst LeekDXSM = 7
    SetConst LeekDYSM = 94
    SetConst LeekAXadj = 4
    SetConst LeekAYadj = 16
    SetConst LeekBXadj = 4
    SetConst LeekBYadj = 16
    SetConst LeekCXadj = 7
    SetConst LeekCYadj =12
    SetConst LeekDXadj = 10
    SetConst LeekDYadj = 9
  End
End
Bell