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

From A Tale in the Desert
Jump to navigationJump to search
 
(14 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
;The AHK icon in system tray will turn red while paused.
 
;The AHK icon in system tray will turn red while paused.
 
;Ctrl+R to reload script
 
;Ctrl+R to reload script
 +
;Date 3/17/2010
 +
;Last Update: 12/17/2010
 +
;Author: Cegaiel
 +
  
^r::reload
 
^p::Pause
 
^!w::
 
  
 
;Wheat is not supported due to the way it brings up a menu and makes you manually select which wheat you are drying
 
;Wheat is not supported due to the way it brings up a menu and makes you manually select which wheat you are drying
Line 24: Line 25:
 
sPapy = 266
 
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
  
  
Line 30: Line 58:
 
{
 
{
 
WinActivate
 
WinActivate
 
+
Gui, +AlwaysOnTop +ToolWindow
 
Gui, Add, Text,, What are you drying?
 
Gui, Add, Text,, What are you drying?
Gui, Add, DropDownList, vWord Choose3, Grass|Papyrus|Rotten Flax
+
Gui, Add, DropDownList, vWord Choose1, Grass|Rotten Flax|Fertile Papyrus|Sterile Papyrus
Gui, Add, Text,, Cycles:
+
Gui, Add, Text,, Qty you have in inventory:
Gui, Add, Edit, vCycles wp number, 100
+
Gui, Add, Edit, vQty wp number,  
Gui, Add, Text,, Cycles = Qty Resources / (Total Hammocks x Max capacity),`nie 100 papyrus using 5 hammocks = 5 cycles`n1 Cycle = Loading, Drying and Taking from ALL hammocks, 1 time`n`nLeave as high number if you will be manually stopping the macro
+
Gui, Add, Text,, `nHammock Max capacity:
Gui, Font, bold
+
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, Text,, Hammock Max capacity:
 
Gui, Font, norm
 
Gui, Add, Text,, Grass: 200`nPapyrus: 20`nRotten Flax: 10`n
 
 
Gui, Add, Button, gRecord, Next
 
Gui, Add, Button, gRecord, Next
Gui, Show
+
Gui, Show, x0 y25
 
return
 
return
  
Line 66: Line 91:
  
 
Gui, Add, Button, default gMineSetLoops, OK
 
Gui, Add, Button, default gMineSetLoops, OK
Gui, Show
+
Gui, Show, x0 y25
  
 
MineNum = 0
 
MineNum = 0
 +
PerCycle = 0
 +
Dried = 0
  
 
+
SetDefaultMouseSpeed, 0
if (Word == "Rotten Flax") {
 
Hammock := "F"
 
Seconds := sFlax
 
 
 
} else if (Word == "Grass") {
 
Hammock := "S"
 
Seconds := sGrass
 
 
 
} else if (Word == "Papyrus") {
 
Hammock := "P"
 
Seconds := sPapy
 
}
 
 
 
  
  
Line 112: Line 126:
 
TotalHammocks := MineNum
 
TotalHammocks := MineNum
 
return
 
return
 +
 +
  
  
Line 117: Line 133:
 
Gui, Submit
 
Gui, Submit
 
Gui, Destroy
 
Gui, Destroy
 +
 +
Msgbox, Make sure your chat is MINIMIZED!`n`nAfter verifying chat is minimized, Click OK to proceed...
 +
 
Gui, +AlwaysOnTop +ToolWindow
 
Gui, +AlwaysOnTop +ToolWindow
 
Gui, Font, bold
 
Gui, Font, bold
Gui, Add, Text, vMineCycleText, 5 seconds to drag window out of way
+
 
Gui, Font, norm
+
Gui, Add, Text, vMineCycleText, 5 seconds countdown to drag this window out of way`n`n`n`n
Gui, Show
+
Gui, Show, x0 y25
GuiControl, Text, MineCycleText, 5 seconds to drag window out of way
+
GuiControl, Text, MineCycleText, 5 seconds countdown to drag this window out of way`n`n`n`n
  
  
seconds = 5
+
StartDelay = 5
 
;You got 5 seconds to drag the status window out of the way
 
;You got 5 seconds to drag the status window out of the way
Loop, %seconds%
+
Loop, %StartDelay%
 
{
 
{
GuiControl, Text, MineCycleText, %seconds%s countdown, drag window out of way
+
GuiControl, Text, MineCycleText, %StartDelay%s countdown to drag this window out of way`n`n`n`n
seconds --
+
StartDelay --
 
Sleep 1000
 
Sleep 1000
 
}
 
}
Line 136: Line 155:
 
SetDefaultMouseSpeed, 0
 
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%
 
loop, %Cycles%
Line 141: Line 200:
  
  
 +
WinActivate, eGenesis Client
 
MineNum = 1
 
MineNum = 1
 
MouseGetPos, OldMX, OldMY
 
MouseGetPos, OldMX, OldMY
Line 155: Line 215:
 
MinePosY := MineY%MineNum%
 
MinePosY := MineY%MineNum%
 
MouseMove, %MinePosX%, %MinePosY%, 0
 
MouseMove, %MinePosX%, %MinePosY%, 0
sleep 200
+
sleep %Delay%
 
Send {%Hammock%}
 
Send {%Hammock%}
Sleep, 200
+
Sleep, %Delay%
 
MineNum++
 
MineNum++
 +
GoSub, Popup
 
}
 
}
  
Line 167: Line 228:
  
 
loop, %Seconds% {
 
loop, %Seconds% {
GuiControl, Text, MineCycleText, Waiting %SecondsCountdown%s for %Word% to dry
+
Gui, Font, bold
SecondsCountdown := SecondsCountdown - 1
+
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
 
sleep 1000
 +
  Gosub, Timer
 
}
 
}
 
 
Line 176: Line 246:
  
 
 
 +
 +
 
;Take Dried Items
 
;Take Dried Items
  
Line 186: Line 258:
 
MinePosY := MineY%MineNum%
 
MinePosY := MineY%MineNum%
 
MouseMove, %MinePosX%, %MinePosY%, 0
 
MouseMove, %MinePosX%, %MinePosY%, 0
Sleep, 200
+
Sleep, %Delay%
 
Send {T}
 
Send {T}
Sleep, 200
+
Sleep, %Delay%
 +
GoSub, Popup
 
MineNum++
 
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
 
}
 
}
  
Line 206: Line 297:
 
return
 
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
 
</pre>
 
</pre>

Latest revision as of 09:42, 17 December 2010

;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/17/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
	StartDelay --
	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