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.

User:Cegaiel/Macros/Wheat2

From A Tale in the Desert
Jump to navigationJump to search
;Ctrl+Alt+W to start macro.
;Ctrl+P to pause script (ie to click Water icon) and Ctrl+P again to resume
;The AHK icon in system tray will turn red while paused.

^p::Pause
^!w::



IfWinExist eGenesis Client
{
	WinActivate
	WinGetPos,,, winWidth, winHeight
	widthOffset := winWidth - 40

	Gui, +AlwaysOnTop +ToolWindow
	Gui, Font, bold
	Gui, Add, Text, vMineNumText, Middle click water icon
	Gui, Font, norm
	Gui, Add, Text,,
	( LTrim
	Hover and middle-click (Click mouse-wheel) on each wheat bed, one by one,
	until you've clicked on all the beds you want to use. Then click the OK button.
	(Drag this box out of the way if any beds are hidden)
	)

	Gui, Add, Button, default gMineSetLoops, OK
	Gui, Show

	MineNum = 0
	MineCycle = 0
	NumPulls = 1000

	WinGet, GameWinHandle, ID, eGenesis Client
	loop
	{
		WinActivate
		CoordMode, Mouse, Relative
		KeyWait, MButton, D
		KeyWait, MButton
		MouseGetPos, TestX, TestY, WinHandle
		if (WinHandle = GameWinHandle)
		{
			Gosub, MineRecord
		}
		else
		{
			Gui, Destroy
			break
		}
	}
	return



			Water: 
			MineNum = 1
			GuiControl, Text, MineCycleText, Fetching Water...
			MinePosX := MineX%MineNum%
			MinePosY := MineY%MineNum%
			MouseGetPos, OldMX, OldMY
			Click, %MinePosX%, %MinePosY%
			Sleep, 500
			Click, 513, 423			
			Sleep, 250
			MouseMove, %OldMX%, %OldMY%, 0			
			return


	MineRecord:
	MineNum++
	MouseGetPos, MineX%MineNum%, MineY%MineNum%

if (MineNum = 1)
{
BedNum = 0
	GuiControl, Text, MineNumText, Middle click wheat beds
}
else
{
BedNum ++
	GuiControl, Text, MineNumText, %BedNum% wheat beds captured
}

	TotalBeds := MineNum-1
	return


	MineSetLoops:
	Gui, Submit
	Gui, Destroy
	Gui, +AlwaysOnTop +ToolWindow
	Gui, Font, bold
	Gui, Add, Text, vMineCycleText, Cycle %NumPulls% of %NumPulls%
	Gui, Font, norm
	Gui, Show
	GuiControl, Text, MineCycleText, Cycle %MineCycle% of %NumPulls%

#Persistent 
;Every 3 mins, get water (180s for 3 mins. SetTimer = s*1000 per min, thus 180,000s for 3 mins)
;Normally each wheat needs watered every 33 seconds, real time, so 3 mins is plenty of time for water icon to appear.
SetTimer, Water, 180000

;You got 7 seconds to drag the status bar out of the way (3s below + and 4 s furthur below
Sleep 3000


	loop, %NumPulls%
	{

				Sleep, 4000
			;MinNum = 1 is the water icon location, thus why we are starting at 2. MineNum = 1 is only called during the #Persistent
			BedNum = 1
			MineNum = 2
			MineCycle++
			MouseGetPos, OldMX, OldMY





	loop, %TotalBeds%
	{



			WinActivate, eGenesis Client

			;BlockInput, MouseMove

			GuiControl, Text, MineCycleText, Cycle %MineCycle%   Bed %BedNum% 
			MinePosX := MineX%MineNum%
			MinePosY := MineY%MineNum%
			MouseMove, %MinePosX%, %MinePosY%, 0
			Send {H}
			Send {W}
			Sleep, 250	
			MineNum++
			BedNum ++
			}

			MouseMove, %OldMX%, %OldMY%, 0			
			GuiControl, Text, MineCycleText, Cycle %MineCycle%   Pause 
			;BlockInput, MouseMoveOff



	}
	Gui, Destroy
	Gui, Add, Text,, Middle-click on this window to end the script.
	Gui, Show
	return
}