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 20:57, 4 April 2011 by Anka (talk | contribs)
(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
  dave = 0
  Loops = 0
  Water = 5
  X1 = 0
  Y1 = 0
  NumX = 4
  NumY = 0
  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 = 50
  CabSY = 66
  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 = 49
  LeekSY = 48
  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 = 12
  CarSY = 38
  CarAYSM = 1
  CarBXSM = 41
  CarCXSM = 48
  CarCYSM = 74
  CarDXSM = 23
  CarDYSM = 58
  CarAXadj = 3
  CarAYadj = 5
  CarBXadj = 3
  CarBYadj = 5
  CarCXadj = 5
  CarCYadj = 10
  CarDXadj = 10
  CarDYadj = 4
  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 = 0
  Oy = 0
  OStep = 41
  ODWX = 169
  ODWY = 0
  ODragX = 4
  ODragY = 90
  ODragYAdd = 60
  OSetWinX = 20
  OWX = 50
  OWY = 120
  OCal = 0
  OJ5 = 0
  OJ10 = 0
  OJ15 = 0
  OJ20 = 0
  OPRow = 0
  OFPX = 0
  OFPY = 0
  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
  M2Delay = 200
  SDelay = 500
  OSx = 35
  OSy = 10
  FO = 0
  FPX = 0
  FPY = 0
  Close = 0
  OPinX = 172
  OPinY = 31
  PinX = 170
  PinY = 28
  Sow = 50, 40
  Res = 0
  Aquaduct = 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

SetConst WaterX = {MouseX}
SetConst WaterY = {MouseY}

Form Veggie, Settings
  ed1=Combobox:Veggie:Cabbage, Carrots, Garlic, Leeks, Onions
  ed2=Editbox:Batch:1
  ed3=Checkbox:Right Action Buttons?:False
  ed5=Checkbox:Aquaduct?:False
  ed6=Checkbox:Venery?:False
  ed7=Editbox:Mouse Delay:100
  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]
  if Veggie[ed5] = True
    SetConst Aquaduct = 1
  End
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
if Veggie[ed6] = True
  Call Venery
End

if $Aquaduct = 0
  call Findbutton
  call water
else
  Call Aqua
End

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
    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
    If {loopno} <> $Loops
      if $Aquaduct = 0
        Call Water
      else
        Call Aqua
      End
    End
    SetConst LeekAX = 0
    SetConst LeekAY = 0
    SetConst LeekA = 0
    SetConst LeekB = 0
    SetConst LeekC = 0
    SetConst LeekD = 0
  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
    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
    
    If {loopno} <> $Loops
      if $Aquaduct = 0
        Call Water
      else
        Call Aqua
      End
    End
    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
    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
        Timestamp $CabCX, $CabCY
        Delay $MDelay
        Call CheckC
      End
      If $CabD < 5
        MousePos $CabDX, $CabDY
        Delay $MDelay
        Call CheckD
      End
    End
    If {loopno} <> $Loops
      if $Aquaduct = 0
        Call Water
      else
        Call Aqua
      End
    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
    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
      if $Aquaduct = 0
        Call Water
      else
        Call Aqua
      End
    End
    
    Delay 5000
    SetConst CarAX = 0
    SetConst CarAY = 0
    SetConst CarA = 0
    SetConst CarB = 0
    SetConst CarC = 0
    SetConst CarD = 0
  End
  
End

Procedure Onions       //----------------Onions----------------//
  Loop $Loops
    Call Plant
    SetConst OFPX = $FPX
    SetConst OFPY = $FPY
    SetConst Onion = 1
    
    Loop $Plants  //Find and Pin Plants
      Delay $M2Delay
      Case
      When {LoopNo} < 6
        Compute FPX = $OFPX - ($OStep * ( {LoopNo} - 1 ))
      When {LoopNo} < 11
        Compute FPX = $OFPX - $OStep * ( {LoopNo} - 6 )
        Compute FPY = $OFPY + $OStep
      When {LoopNo} < 16
        Compute FPX = $OFPX - $OStep * ( {LoopNo} - 11 )
        Compute FPY = $OFPY + $OStep * 2
      When {LoopNo} < 21
        Compute FPX = $OFPX - $OStep * ( {LoopNo} - 16 )
        Compute FPY = $OFPY + $OStep * 3
      When {LoopNo} < 26
        Compute FPX = $OFPX - $OStep * ( {LoopNo} - 21 )
        Compute FPY = $OFPY + $OStep * 4
      End
      Call CheckOnions
    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 - $OSetWinX
        MousePos $OWX, $NewY
        Delay $M2Delay
        Rightclick
        Delay $M2Delay
        Mousepos $OWX, $OWY
        Delay $M2Delay
        Rightclick  //waters
        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} + $ODragYAdd  //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
    SetConst Close = 0
    //Compute Ox = 495
    //Compute Oy = 380
    Call Resolution
    If Veggie[ed6] = True
      Call Venery
    End
    If {loopno} <> $Loops
      if $Aquaduct = 0
        Call Water
      else
        Call Aqua
      End
    End
    Compute OWX = 50
    Compute OWY = 120
  End
End

Procedure Plant  //For Onions
  Loop $Plants  //Number of plants
    Call Sow
    Case
    When $Onion < 6
      SetConst OPRow = 0
    When $Onion < 11
      SetConst OPRow = 1
    When $Onion < 16
      SetConst OPRow = 2
    When $Onion < 21
      SetConst OPRow = 3
    When $Onion < 26
      SetConst OPRow = 4
    End
    
    Compute NumY = $OPRow * 2
    MousePos 59, 120
    Delay $MDelay
    If $NumY > 0
      Loop $NumY
        Rightclick
      End
    End
    
    MousePos 37, 97
    Delay $MDelay
    Case
    When $Onion < 6
      Compute NumX = $Onion * 2
    When $Onion < 11
      Compute NumX = $Onion * 2 - 10
    When $Onion < 16
      Compute NumX = $Onion * 2  - 20
    When $Onion < 21
      Compute NumX = $Onion * 2 - 30
    When $Onion < 26
      Compute NumX = $Onion * 2 - 40
    End
    
    Loop $NumX
      Rightclick
    End
    
    // New Routine to find onions before plant
    If {loopno} = 1
      Compute Ox = $CenterX - $OSx
      Compute Oy = $CenterY - $OSy
      Mousepos $Ox, $Oy
      Delay $MDelay
      Loop 40
        RightClick
        IsObject Plant at {MouseX}, {MouseY}
          SetConst FPY = {MouseY}
          SetConst TopX = {MouseX}
          Compute TopY = {MouseY} + 2
          //SetConst TopY = {MouseY}
          Keys {Esc}
          Delay $MDelay
          Call FindLeft
          Set Done = 0
          Call FindRight
          Set Done = 0
          Compute OCal = $RightX - $LeftX
          Compute Result = $RightX - ($RightX - $LeftX)/2
          Formatnumber FPX = $Result, ###
          Case
          When $Ocal < 5
            //Do Nothing
          When $Ocal < 11
            Compute FPX = $FPX + 2
            //Bell
          When $Ocal > 20
            Compute FPX = $RightX - 7
            //Bell
            //Delay 500
            //Bell
          End
          Break
        Else
          Compute Oy = $Oy + 1
          MousePos $OX, $Oy
          Delay $MDelay
        End
      End
    End
    Compute Onion = $Onion + 1
    
    Call Build
  End
End

Procedure CheckOnions
  //Check here to see if window is actually there
  While $Done = 0
    MousePos $FPX, $FPY
    Delay $SDelay
    Rightclick
    Delay 100
    IsObject Plant at {mousex}, {mousey}
      Break
    Else
      dec $FPX
    End
  End
  Compute NewX = {mousex} + $OPinX
  Compute NewY = {mousey} - $OPinY   //23
  MousePos $NewX, $NewY
  Delay $SDelay //$M2Delay
  Rightclick  //Pin
  Compute NewX = {mousex} - $ODWX  //169
  MousePos $NewX, $NewY  //left edge of window before drag
  if $Onion > 8
    Dragto $ODragX, $ODragY
    Compute ODragY = $ODragY + $ODragYAdd
  End
  if $Onion = 5 or $Onion = 6 or $Onion = 7 or $Onion = 8
    Dragto $ODragX, $ODragY
    Compute ODragY = $ODragY + $ODragYAdd
  End
  If $Onion = 2 or $Onion = 3 or $Onion = 4
    Dragto $ODragX, $ODragY
    Compute ODragY = $ODragY + $ODragYAdd
  End
  if $Onion = 1
    Dragto $ODragX, $ODragY
    Compute ODragY = $ODragY + $ODragYAdd
  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 Aqua
  Delay 2000
  Compute NewY = $WaterY - 40
  MousePos $WaterX, $NewY
  Delay $M2Delay
  Rightclick
  Delay $M2Delay
  MousePos $WaterX, $WaterY
  Delay $M2Delay
  Rightclick
  Delay $M2Delay
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

Function CheckforLostFocus
  if {activewindow} contains eGenesis
    Compute Result = 0
    Exit
  Else
    Stop
  End
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 = 26
    SetConst CabDYadj = 10
    //Carrots
    SetConst CarSX = 23
    SetConst CarSY = 78
    SetConst CarAYSM = 1
    SetConst CarBXSM = 77
    SetConst CarCXSM = 88
    SetConst CarCYSM = 137  //115
    SetConst CarDXSM = 41   //25
    SetConst CarDYSM = 110  //105
    SetConst CarAXadj = 8
    SetConst CarAYadj = 10
    SetConst CarBXadj = 8
    SetConst CarBYadj = 10
    SetConst CarCXadj = 10  //8
    SetConst CarCYadj = 21  //10
    SetConst CarDXadj = 20  //8
    SetConst CarDYadj = 6   //5
    //Garlic
    SetConst GarSX = 55
    SetConst GarSY = 69
    SetConst GarAYSM = 2
    SetConst GarBXSM = 79
    SetConst GarCXSM = 67
    SetConst GarCYSM = 139
    SetConst GarDXSM = 11
    SetConst GarDYSM = 139
    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 = 108
    SetConst LeekCYSM = 158
    SetConst LeekDXSM = 9
    SetConst LeekDYSM = 135
    SetConst LeekAXadj = 8 //3
    SetConst LeekAYadj = 20
    SetConst LeekBXadj = 3
    SetConst LeekBYadj = 26
    SetConst LeekCXadj = 11
    SetConst LeekCYadj = 15
    SetConst LeekDXadj = 15
    SetConst LeekDYadj = 11
    //Onions
    SetConst OSx = 78
    SetConst OSy = 29
    SetConst ResetX = 1135
    SetConst ResetY = 556
    SetConst OStep = 76
    SetConst OPinX = 172
    SetConst OPinY = 30
    SetConst ODragYAdd = 60
    
  When $Res = 1280x1024
    //Cabbage
    SetConst CabSX = 53
    SetConst CabSY = 80
    SetConst CabBXSM = 51
    SetConst CabBYSM = 1
    SetConst CabCXSM = 77
    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 = 13
    SetConst CarSY = 58
    SetConst CarAYSM = 1
    SetConst CarBXSM = 52
    SetConst CarCXSM = 58
    SetConst CarCYSM = 93
    SetConst CarDXSM = 30
    SetConst CarDYSM = 72
    SetConst CarAXadj = 4
    SetConst CarAYadj = 8
    SetConst CarBXadj = 4
    SetConst CarBYadj = 8
    SetConst CarCXadj = 7
    SetConst CarCYadj = 13
    SetConst CarDXadj = 13
    SetConst CarDYadj = 4
    //Onions
    //SetConst Ox = 618
    //SetConst Oy = 487
    SetConst OSx = 44
    SetConst OSy = 24
    SetConst ResetX = 707
    SetConst ResetY = 531
    SetConst OStep = 52
    SetConst OPinX = 172
    SetConst OPinY = 31
    SetConst ODragYadd = 60
    //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 = 50
    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 = 51
    SetConst CabSY = 81
    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 = 14
    SetConst CarSY = 61
    SetConst CarAYSM = 1
    SetConst CarBXSM = 56
    SetConst CarCXSM = 63
    SetConst CarCYSM = 95
    SetConst CarDXSM = 31
    SetConst CarDYSM = 77
    SetConst CarAXadj = 4
    SetConst CarAYadj = 8
    SetConst CarBXadj = 4
    SetConst CarBYadj = 8
    SetConst CarCXadj = 7
    SetConst CarCYadj = 17
    SetConst CarDXadj = 13
    SetConst CarDYadj = 3
    //Onions
    SetConst OSx = 62
    SetConst OSy = 19
    SetConst ResetX = 805
    SetConst ResetY = 402
    SetConst OStep = 55
    SetConst OPinX = 178
    SetConst OPinY = 30
    SetConst ODragYAdd = 60
    //Garlic
    SetConst GarSX = 34
    SetConst GarSY = 50
    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 = 13
    SetConst LeekDXadj = 10
    SetConst LeekDYadj = 9
  End
End

Procedure Venery
  Compute ODragYAdd = $ODragYAdd + 16
  
End
Bell