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/FlaxHammock/Code

From A Tale in the Desert
< User:Cegaiel‎ | Macros‎ | FlaxHammock
Revision as of 20:16, 13 December 2010 by Cegaiel (talk | contribs)
Jump to navigationJump to search
;Ctrl+P to pause script and Ctrl+P again to resume
;The AHK icon in system tray will turn red while paused.
;Ctrl+R to reload script
;Date 3/17/2010
;Last Update: 12/13/2010
;Author: Cegaiel



;Wheat is not supported due to the way it brings up a menu and makes you manually select which wheat you are drying

;This is the times based on using 1 hammock. However, the more hammocks you have, the less seconds you will need
;The reason is because the timer doesn't start until the last hammock is loaded.
;If you have 20 hammocks, then it might take 10 seconds to load them all. In that case it would be 10 seconds less

;Rotten flax = 2 Teppy Mins (2:13 real time / 133 seconds)
;Grass = 10 Teppy Mins (11:06 real time / 666 seconds)
;Papy = 4 Teppy Mins (4:26 real time / 266 seconds)


;Time in seconds, 
sFlax = 133
sGrass = 666
sPapy = 266





			// CONFIGURATION


			;Set Delay to 100-150 for fast computer/not much lag. 250 for slower computer.

			Delay = 125



			;Set PopupDelay to 150-200 for fast computer, about 250+ for slower computers (or lots of lag)

			PoupDelay = 200


			// END CONFIGURATION





			;Get coordinates, for your resolutions'  X,Y location of the popups (OK button) that will occur 

later.
			CenterX := Floor(Xmax/2)
			CenterY := Floor(Ymax/2)+105



IfWinExist eGenesis Client
{
	WinActivate
	Gui, +AlwaysOnTop +ToolWindow
	Gui, Add, Text,, What are you drying?
	Gui, Add, DropDownList, vWord Choose1, Grass|Rotten Flax|Fertile Papyrus|Sterile Papyrus
	Gui, Add, Text,, Qty you have in inventory:
	Gui, Add, Edit, vQty wp number, 
	Gui, Add, Text,, `nHammock Max capacity:
	Gui, Add, Text,, Grass: 200   (2 Teppy Min max)`nPapyrus: 20   (4 Teppy Min max)`nRotten Flax: 10   (2 Teppy Min 

max)`n
	Gui, Add, Button, gRecord, Next
	Gui, Show, x0 y25
	return


	Record:
	Gui, Submit
	Gui, Destroy
	Gui, +AlwaysOnTop +ToolWindow
	Gui, Font, bold
	Gui, Add, Text, vMineNumText, Record hammock locations
	Gui, Font, norm
	Gui, Add, Text,,
	( LTrim
	Hover and middle-click (Click mouse-wheel) on each hammock, one by one,
	until you've clicked on all the hammocks you want to use. Then click the OK button.

	(Drag this box out of the way if any hammocks are hidden)

	Make sure you chat is minimized and that your screen is locked (Alt+L)

	AFTER setting hammock locations, Press OK...

	)

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

	MineNum = 0
	PerCycle = 0
	Dried = 0

SetDefaultMouseSpeed, 0


	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

	MineRecord:
	MineNum++
	MouseGetPos, MineX%MineNum%, MineY%MineNum%
	GuiControl, Text, MineNumText, %MineNum% hammocks captured
	TotalHammocks := MineNum
	return




	MineSetLoops:
	Gui, Submit
	Gui, Destroy

	Msgbox, Make sure your chat is MINIMIZED!`n`nAfter verifying chat is minimized, Click OK to proceed...

	Gui, +AlwaysOnTop +ToolWindow
	Gui, Font, bold

	Gui, Add, Text, vMineCycleText, 5 seconds countdown to drag this window out of way`n`n`n`n
	Gui, Show, x0 y25
	GuiControl, Text, MineCycleText, 5 seconds countdown to drag this window out of way`n`n`n`n


	StartDelay = 5
	;You got 5 seconds to drag the status window out of the way
	Loop, %StartDelay%
	{
	GuiControl, Text, MineCycleText, %StartDelay%s countdown to drag this window out of way`n`n`n`n
	Delay --
	Sleep 1000
	}

SetDefaultMouseSpeed, 0




	if (Word == "Rotten Flax") {
	Hammock := "F"
	Seconds := sFlax
	Cycles := Ceil(Qty / (10 * TotalHammocks))
	PerHammock := 10
	minutes_eta = 2
	seconds_eta = 13

	} else if (Word == "Grass") {
	Hammock := "S"
	Seconds := sGrass
	Cycles := Ceil(Qty / (200 * TotalHammocks))
	PerHammock := 200
	minutes_eta = 11
	seconds_eta = 6

	} else if (Word == "Fertile Papyrus") {
	Hammock := "P"
	Seconds := sPapy
	Cycles := Ceil(Qty / (20 * TotalHammocks))
	PerHammock := 20
	minutes_eta = 4
	seconds_eta = 26


	} else if (Word == "Sterile Papyrus") {
	Hammock := "N"
	Seconds := sPapy
	Cycles := Ceil(Qty / (20 * TotalHammocks))
	PerHammock := 20
	minutes_eta = 4
	seconds_eta = 26
	}


PerCycle := PerHammock * MineNum
Remaining := Cycles

	loop, %Cycles%
	{


			WinActivate, eGenesis Client
			MineNum = 1
			MouseGetPos, OldMX, OldMY


	;Dry Hammock Loop
	loop, %TotalHammocks% {

			WinActivate, eGenesis Client

			;BlockInput, MouseMove
			GuiControl, Text, MineCycleText, Drying %Word% -  Hammock: %MineNum% 
			MinePosX := MineX%MineNum%
			MinePosY := MineY%MineNum%
			MouseMove, %MinePosX%, %MinePosY%, 0
			sleep %Delay%
			Send {%Hammock%}
			Sleep, %Delay%	
			MineNum++
			GoSub, Popup
			}


			MouseMove, %OldMX%, %OldMY%, 0		

			SecondsCountDown := Seconds

			loop, %Seconds% {
			Gui, Font, bold
			GuiControl, Text, MineCycleText, %minutes_eta%m %seconds_eta%s drying time remaining 

(%Word%)`n`n%Remaining% of %cycles% cycles remaining to process `n`nDried: %Dried% of %Qty%
			Gui, Font, norm
			Gui, Add, Text,,
			( LTrim
	
			%Remaining% cycles remaining to process: %Word%`nDried: %Dried%
			)

			;SecondsCountdown := SecondsCountdown - 1
			sleep 1000
  			Gosub, Timer
			}
	
			MineNum = 1


			


			;Take Dried Items

			loop, %TotalHammocks% {

			WinActivate, eGenesis Client

			GuiControl, Text, MineCycleText, Taking %Word% -  Hammock: %MineNum% 
			MinePosX := MineX%MineNum%
			MinePosY := MineY%MineNum%
			MouseMove, %MinePosX%, %MinePosY%, 0
			Sleep, %Delay%	
			Send {T}
			Sleep, %Delay%	
			GoSub, Popup
			MineNum++
			}

			Remaining --
			Dried := Dried + PerCycle

			;Set the minutes/seconds countdown again, for next cycle
			if (Word == "Rotten Flax") {
			minutes_eta = 2
			seconds_eta = 13
			} else if (Word == "Grass") {
			minutes_eta = 11
			seconds_eta = 6
			} else if (Word == "Fertile Papyrus") {
			minutes_eta = 4
			seconds_eta = 26
			} else if (Word == "Sterile Papyrus") {
			minutes_eta = 4
			seconds_eta = 26
			}




			GuiControl, Text, MineCycleText, 2s Pause, Hit Ctrl+P to STOP HAMMOCKS 
			Sleep 2000


	} 

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



			Popup:

			;Search for the RBG color of 0xECDFBD (Same as HTML code: #ECDFBD)

			PixelSearch, Px, Py, %CenterX%, %CenterY%, %CenterX%, %CenterY%, 0xEBDDBB, %shade%, Fast|RGB

			if ErrorLevel = 0
			{
			MouseMove, %CenterX%, %CenterY%
			Sleep %PopupDelay%
			Click
			Sleep %PopupDelay%
			}
			return



		Timer:
		
		if (seconds_eta = 0) and !(minutes_eta = 0)
		{
		seconds_eta := 60
		minutes_eta --
		}
		
		if (minutes_eta < 0)
		minutes_eta := 0

		seconds_eta --
		return



^r::reload
^p::Pause