The Wiki for Tale 4 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.

Difference between revisions of "User:Cegaiel/Macros/Barley/Code"

From A Tale in the Desert
Jump to navigationJump to search
(New page: ;Barley Macro written for http://www.autohotkey.com, 1280x1024 resolution, pin window in the upper left corner of the screen. ;Have 59 Grain Fertilizer and 59 jugs of water, in inventory...)
 
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
;Barley Macro written for http://www.autohotkey.com, 1280x1024 resolution, pin window in the upper left corner of the screen.  
+
<pre>
 +
;Barley Macro written for http://www.autohotkey.com, 1280x1024 resolution, pin plant window in the upper left corner of the screen.  
 +
 
 +
;Have 10 Raw Barley, 60 Grain Fertilizer and 60 jugs of water, in inventory, for "Water + 6 fertilizer" mode
 +
;Have 10 Raw Barley, 30 Grain Fertilizer and 60 jugs of water, in inventory, for "Water + 3 fertilizer" mode
 +
;Have 10 Raw Barley, 0 Grain Fertilizer and 60 jugs of water, in inventory, for "Water only" mode
  
;Have 59 Grain Fertilizer and 59 jugs of water, in inventory, each time you start this script
 
  
 
; Barley - 1280x1024 resolution
 
; Barley - 1280x1024 resolution
; Ctrl+Alt+W
+
 
 +
; Ctrl+Alt+W to Start script
 +
; Ctrl+R to Reload script
 +
; Ctrl+P to Pause script
 +
 
 +
 
 +
; Author: Cegaiel
 +
; Based on Daniels barley macro
 +
; Date: 6/3/2010
 +
; Updated: 9/17/2010 for T5 (No adjustments were required, however I somehow deleted the "interval = 1200" line
 +
; on the T4 version which caused the script to fail miserably when I tried it on T5. That line is now added and works fine now
 +
; Updated: 10/16/2010 - I attempted to revamp the script to automatically start without Ctrl+Alt+W, but some reason this made it misclick very badly.
 +
; Restored back to previous version, which includes the 9/17/2010 update
  
  
Line 15: Line 31:
 
IfWinExist eGenesis Client
 
IfWinExist eGenesis Client
 
{
 
{
 +
WinActivate, eGenesis Client
 +
 
WinGetActiveStats, win_Title, Xmax, Ymax, win_Xpos, win_Ypos
 
WinGetActiveStats, win_Title, Xmax, Ymax, win_Xpos, win_Ypos
SetDefaultMouseSpeed, 1
+
SetDefaultMouseSpeed, 0
 
interval = 1200
 
interval = 1200
 
 
Line 30: Line 48:
 
}
 
}
  
 +
 +
 +
Gui, +AlwaysOnTop +ToolWindow
 +
Gui, Font, bold
 +
Gui, Add, Text,, Adjust Camera/Zoom Level?
 +
Gui, Font, normal
 +
Gui, Add, Text,, Choose Yes if this is the first time running.`nChoose No if you already performed this step and locked screen.
 +
Gui, Add, DropDownList, vAdjust Choose2, Yes|No
 +
 +
 +
Gui, Font, bold
 +
Gui, Add, Text,, `nChoose method/fertilizer qty:
 +
Gui, Font, normal
 +
;Gui, Add, Text,,
 +
Gui, Add, DropDownList, vMethod Choose3, Water + 3 fertilizer|Water + 6 fertilizer|Water only
  
  
  
 +
Gui, Add, Button, Default gStart, GO
 +
Gui, Show
 +
return
 +
 +
 +
 +
Start:
 +
Gui, Submit
 +
Gui, Destroy
 +
Sleep 250
 +
 +
if (Adjust = "Yes")
 +
{
  
 
;Now Zoom in all the way with F8
 
;Now Zoom in all the way with F8
Line 46: Line 92:
 
Ycenter := Ymax//2 + 16
 
Ycenter := Ymax//2 + 16
 
MouseMove, Xcenter, Ycenter, 0
 
MouseMove, Xcenter, Ycenter, 0
 
  
  
Line 52: Line 97:
 
Loop, 8
 
Loop, 8
 
{
 
{
MouseClick, WD
+
click, WD
 
sleep 250
 
sleep 250
 
}
 
}
  
 +
Sleep 2000
 +
 +
Msgbox, Screen adjusted, Lock screen (Alt+L) NOW so you wont have to repeat this step on next plantings.`n`nDon't forget to make sure you have your Plant menu in top left corner before continuing!`n`nClick OK when you are ready to continue...
  
Msgbox, Screen adjusted, hit OK when you are ready to continue...
+
}
 +
 
 +
Plant:
 +
 
 +
WinActivate, eGenesis Client
  
 
Loop, 100
 
Loop, 100
Line 75: Line 127:
 
MouseMove, 30, 45
 
MouseMove, 30, 45
 
sleep 100
 
sleep 100
MouseClick, Left ; Plant
+
click, Left ; Plant
 
sleep 100
 
sleep 100
 
MouseMove, mousex + incx, mousey
 
MouseMove, mousex + incx, mousey
 
sleep 100
 
sleep 100
MouseClick, Left
+
click, Left
 
sleep interval
 
sleep interval
 
}
 
}
Line 86: Line 138:
 
MouseMove, 30, 45
 
MouseMove, 30, 45
 
sleep 100
 
sleep 100
MouseClick, Left ; Plant
+
click, Left ; Plant
 
sleep 100
 
sleep 100
 
MouseMove, mousex - incx, mousey
 
MouseMove, mousex - incx, mousey
 
sleep 100
 
sleep 100
MouseClick, Left
+
click, Left
 
sleep interval
 
sleep interval
 
}
 
}
Line 96: Line 148:
 
MouseMove, 30, 45
 
MouseMove, 30, 45
 
sleep 100
 
sleep 100
MouseClick, Left ; Plant
+
click, Left ; Plant
 
sleep 100
 
sleep 100
 
MouseMove, mousex, mousey + incy
 
MouseMove, mousex, mousey + incy
 
sleep 100
 
sleep 100
MouseClick, Left
+
click, Left
 
sleep interval
 
sleep interval
 
rows++
 
rows++
}
+
}
 +
 
 +
 
 +
 
 +
 
; Begin watering and fertalizing
 
; Begin watering and fertalizing
 
water = 0
 
water = 0
Line 115: Line 171:
 
Loop, 2
 
Loop, 2
 
{
 
{
 +
 +
 +
 +
 +
 
Loop, 5
 
Loop, 5
 
{
 
{
 +
 +
Gosub, Calc
 +
 
if (count = 0) ; water and fert twice
 
if (count = 0) ; water and fert twice
 
{
 
{
MouseMove, mousex + intx, mousey + inty
+
Click, %x%, %y%
sleep 300
+
Sleep 250
MouseClick, Left
+
 
sleep 300
+
;Water
MouseMove, mousex + intx + 189, mousey + inty + 23
+
click, %WaterX%, %WaterY%
sleep 100
+
Sleep 250
MouseClick, Left
+
click, %WaterX%, %WaterY%
sleep 100
+
 
MouseMove,  mousex + intx + 189, mousey + inty + 23
+
sleep 100
+
if !(Method = "Water only")
MouseClick, Left
+
{
sleep 100
+
Sleep 250
MouseMove, mousex + intx + 189, mousey + inty + 46
+
;Fert
sleep 100
+
click, %FertX%, %FertY%
MouseClick, Left
+
Sleep 250
sleep 100
+
click, %FertX%, %FertY%
MouseMove, mousex + intx + 189, mousey + inty + 46
+
}
sleep 100
+
 
MouseClick, left
+
Sleep 250
sleep 200
 
 
SendInput {ESC}
 
SendInput {ESC}
sleep 300
+
sleep 350
 
intx += 70
 
intx += 70
 +
 +
Gosub, Calc
 +
 +
 +
}
 +
else if (count = 3) and (Method = "Water + 3 fertilizer") ; water and fert once
 +
{
 +
click, %x%, %y%
 +
Sleep 250
 +
click, %waterX%, %waterY%
 +
Sleep 250
 +
click, %FertX%, %FertY%
 +
 +
Sleep 250
 +
SendInput {ESC}
 +
sleep 350
 +
intx += 70
 +
 +
Gosub, Calc
 +
 +
 
}
 
}
 
else if (count = 5) ; harvest
 
else if (count = 5) ; harvest
 
{
 
{
MouseMove, mousex + intx, mousey + inty
+
click, %x%, %y%
sleep 300
+
Sleep 250
MouseClick, Left
+
click, %harvestX%, %harvestY%
sleep 300
+
 
MouseMove, mousex + intx + 106, mousey + inty + 86
+
Sleep 250
sleep 100
 
MouseClick, Left
 
sleep 200
 
 
SendInput {ESC}
 
SendInput {ESC}
sleep 300
+
sleep 500
 
intx += 70
 
intx += 70
 +
Gosub, Calc
 +
 
}
 
}
 
else ; water and fert once
 
else ; water and fert once
 
{
 
{
MouseMove, mousex + intx, mousey + inty
+
click, %x%, %y%
sleep 300
+
Sleep 250
MouseClick, Left
+
 
sleep 300
+
;Water
MouseMove, mousex + intx + 189, mousey + inty + 23
+
click, %waterX%, %waterY%
sleep 100
+
 
MouseClick, Left
+
if (Method = "Water + 6 fertilizer")
sleep 100
+
{
MouseMove, mousex + intx + 189, mousey + inty + 46
+
;Fert
sleep 100
+
Sleep 250
MouseClick, left
+
click, %FertX%, %FertY%
sleep 200
+
}
 +
 
 +
Sleep 250
 
SendInput {ESC}
 
SendInput {ESC}
sleep 300
+
sleep 350
 
intx += 70
 
intx += 70
 +
Gosub, Calc
 
}
 
}
 
}
 
}
Line 179: Line 265:
 
intx = 0
 
intx = 0
 
inty += 90
 
inty += 90
 +
Gosub, Calc
 
}
 
}
 
count++
 
count++
  
  
sleep 5000
+
 
 +
if (count = 5)
 +
{
 +
sleep 25000 ;Last cycle, let is sit for 25s, usually get more barley
 +
} else if (count = 6) {
 +
Sleep 0
 +
} else{
 +
sleep 6000
 +
}
 +
 
 +
 
 +
 
 
}
 
}
  
EXIT
+
Msgbox, Done! Click OK`n`nPress Press F2 if you want to plant again...`n`nFirst gather water and stand on a good spot, if you will continue.
 +
KeyWait, F2, D
 +
Gosub, Plant
 +
 
 +
 
 +
;EXIT
  
  
;PixelSearch, PX, PY, 965, 702, 965, 704, 0x000000, Fast
 
;if (ErrorLevel < 1)
 
;{
 
;MouseClick, Left, 965, 703
 
;return
 
;}
 
 
}
 
}
 
}
 
}
 +
 +
 +
Calc:
 +
;Bed 1 Location
 +
x := mousex + intx
 +
y := mousey + inty
 +
 +
waterX := mousex + intx + 189
 +
waterY := mousey + inty + 23
 +
 +
FertX := mousex + intx + 189
 +
FertY := mousey + inty + 46
 +
 +
HarvestX := mousex + intx + 106
 +
HarvestY := mousey + inty + 86
 +
return
 +
</pre>

Latest revision as of 01:47, 17 October 2010

;Barley Macro written for http://www.autohotkey.com, 1280x1024 resolution, pin plant window in the upper left corner of the screen. 

;Have 10 Raw Barley, 60 Grain Fertilizer and 60 jugs of water, in inventory, for "Water + 6 fertilizer" mode
;Have 10 Raw Barley, 30 Grain Fertilizer and 60 jugs of water, in inventory, for "Water + 3 fertilizer" mode
;Have 10 Raw Barley, 0 Grain Fertilizer and 60 jugs of water, in inventory, for "Water only" mode


; Barley - 1280x1024 resolution

; Ctrl+Alt+W to Start script
; Ctrl+R to Reload script
; Ctrl+P to Pause script


; Author: Cegaiel
; Based on Daniels barley macro
; Date: 6/3/2010
; Updated: 9/17/2010 for T5 (No adjustments were required, however I somehow deleted the "interval = 1200" line
; on the T4 version which caused the script to fail miserably when I tried it on T5. That line is now added and works fine now
; Updated: 10/16/2010 - I attempted to revamp the script to automatically start without Ctrl+Alt+W, but some reason this made it misclick very badly.
; Restored back to previous version, which includes the 9/17/2010 update



^r::reload
^p::Pause
^!w::


IfWinExist eGenesis Client
{
	WinActivate, eGenesis Client

	WinGetActiveStats, win_Title, Xmax, Ymax, win_Xpos, win_Ypos
	SetDefaultMouseSpeed, 0
	interval = 1200
	


;Check to see if we are in the correct resolution, or else exit script
if (Xmax = 1288) && (Ymax = 1002)
{
nothing = 0
} else {
Msgbox, You are not in 1280x1024 resolution`n`nExiting...
EXIT
}



	Gui, +AlwaysOnTop +ToolWindow
	Gui, Font, bold
	Gui, Add, Text,, Adjust Camera/Zoom Level?
	Gui, Font, normal
	Gui, Add, Text,, Choose Yes if this is the first time running.`nChoose No if you already performed this step and locked screen.
	Gui, Add, DropDownList, vAdjust Choose2, Yes|No


	Gui, Font, bold
	Gui, Add, Text,, `nChoose method/fertilizer qty:
	Gui, Font, normal
	;Gui, Add, Text,, 
	Gui, Add, DropDownList, vMethod Choose3, Water + 3 fertilizer|Water + 6 fertilizer|Water only



	Gui, Add, Button, Default gStart, GO
	Gui, Show
	return



Start:
	Gui, Submit
	Gui, Destroy
	Sleep 250

if (Adjust = "Yes")
{

;Now Zoom in all the way with F8
	WinActivate, eGenesis Client
	Sleep 1000
	Send {F5}{F8}{F8}
	MouseMove, 0,0
	Sleep 5000
	MouseMove, 0, 0
	Sleep 5000

	Xcenter := Xmax//2 - 3
	Ycenter := Ymax//2 + 16
	MouseMove, Xcenter, Ycenter, 0


	; Zoom out a little
	Loop, 8
	{
		click, WD
		sleep 250
	}

Sleep 2000

Msgbox, Screen adjusted, Lock screen (Alt+L) NOW so you wont have to repeat this step on next plantings.`n`nDon't forget to make sure you have your Plant menu in top left corner before continuing!`n`nClick OK when you are ready to continue...

}

Plant:

	WinActivate, eGenesis Client

	Loop, 100
	{
		mousex := Xmax//2 - 3
		mousey := Ymax//2 + 16
		incx = 70
		incy = 70
		rows = 0
		Loop, 2 ; columns of barley
		{
			bug = 0
			Loop, 4 ; rows of barley
			{
				if (Mod(rows, 2) = 0) ; plant left to right
				{
					MouseMove, 30, 45
					sleep 100
					click, Left ; Plant
					sleep 100
					MouseMove, mousex + incx, mousey
					sleep 100
					click, Left
					sleep interval
				}
				else ; plant right to left
				{
					MouseMove, 30, 45
					sleep 100
					click, Left ; Plant
					sleep 100
					MouseMove, mousex - incx, mousey
					sleep 100	
					click, Left
					sleep interval
				}
			}
			MouseMove, 30, 45
			sleep 100
			click, Left ; Plant
			sleep 100
			MouseMove, mousex, mousey + incy
			sleep 100
			click, Left
			sleep interval	
			rows++
		}



	
		; Begin watering and fertalizing
		water = 0
		count = 0
		Loop, 6
		{
			mousex = 640
			mousey = 375
			intx = 0
			inty = 0
			Loop, 2
			{





				Loop, 5
				{

					Gosub, Calc

					if (count = 0) ; water and fert twice
					{
						Click, %x%, %y%
						Sleep 250

						;Water
						click, %WaterX%, %WaterY%
						Sleep 250
						click, %WaterX%, %WaterY%

					
					if !(Method = "Water only")
					{
						Sleep 250
						;Fert
						click, %FertX%, %FertY%
						Sleep 250
						click, %FertX%, %FertY%
					}

						Sleep 250
						SendInput {ESC}
						sleep 350
						intx += 70	

						Gosub, Calc


					}
					else if (count = 3) and (Method = "Water + 3 fertilizer") ; water and fert once
					{
						click, %x%, %y%
						Sleep 250
						click, %waterX%, %waterY%
						Sleep 250
						click, %FertX%, %FertY%

						Sleep 250
						SendInput {ESC}
						sleep 350
						intx += 70

						Gosub, Calc


					}
					else if (count = 5) ; harvest
					{
						click, %x%, %y%
						Sleep 250
						click, %harvestX%, %harvestY%

						Sleep 250
						SendInput {ESC}
						sleep 500
						intx += 70
						Gosub, Calc

					}
					else ; water and fert once
					{
						click, %x%, %y%
						Sleep 250

						;Water
						click, %waterX%, %waterY%

					if (Method = "Water + 6 fertilizer") 
					{
						;Fert
						Sleep 250
						click, %FertX%, %FertY%
					}

						Sleep 250
						SendInput {ESC}
						sleep 350
						intx += 70	
						Gosub, Calc
					}
				}
				mousex = 640
				intx = 0
				inty += 90
				Gosub, Calc
			}
			count++



			if (count = 5)
			{
			sleep 25000 ;Last cycle, let is sit for 25s, usually get more barley
			} else if (count = 6) {
			Sleep 0
			} else{
			sleep 6000
			}



		}

	Msgbox, Done! Click OK`n`nPress Press F2 if you want to plant again...`n`nFirst gather water and stand on a good spot, if you will continue.
	KeyWait, F2, D
	Gosub, Plant


		;EXIT


	}
}


Calc:
;Bed 1 Location
x := mousex + intx
y := mousey + inty

waterX := mousex + intx + 189
waterY := mousey + inty + 23

FertX := mousex + intx + 189
FertY := mousey + inty + 46

HarvestX := mousex + intx + 106
HarvestY := mousey + inty + 86
return