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.

Difference between revisions of "Takhetu/Code"

From ATITD5
Jump to navigationJump to search
Line 83: Line 83:
  
 
NoKnobsMoved := True
 
NoKnobsMoved := True
;~ Reverse Direction Sliders
+
 
If (Knob3<>oldKnob3) ;knob moved
+
;~ Reverse Direction Sliders
 +
;~ If (Knob3<>oldKnob3) ;knob moved
 +
;~ {
 +
;~ NoKnobsMoved := False
 +
;~ If (Knob3>oldKnob3) ;knob rose
 +
;~ {
 +
;~ If (Knob3>Knob7) ;Knob3 is above knob7, knobs are spreading out
 +
;~ {
 +
;~ MouseClick,Left,ButtonX2,ButtonY
 +
;~ }
 +
;~ } else {
 +
;~ If (Knob3<Knob7) ;Knob3 is bellow knob7, knobs are spreading out
 +
;~ {
 +
;~ MouseClick,Left,ButtonX2,ButtonY
 +
;~ }
 +
;~ }
 +
;~ oldKnob3 := Knob3
 +
;~ oldKnob7 := Knob7
 +
;~ }
 +
 
 +
 
 +
;~ ********************
 +
;~ COMMENTED SECTION, USE THIS FOR DOUBLE SLIDERS THAT TRAVEL IN THE SAME DIRECTION
 +
;~ ********************
 +
;~ Same Direction Sliders
 +
If (Knob4<>oldKnob4) ;knob moved
 
{
 
{
 
NoKnobsMoved := False  
 
NoKnobsMoved := False  
If (Knob3>oldKnob3) ;knob rose
+
averagePos := floor((Knob4+Knob6)/2)
 +
If (Knob4>oldKnob4) ;knobs are going up
 
{
 
{
If (Knob3>Knob7) ;Knob3 is above knob7, knobs are spreading out
+
If averagePos>0 ;averageposition is above center
 
{
 
{
MouseClick,Left,ButtonX2,ButtonY
+
MouseClick,Left,ButtonX4,ButtonY
 
}
 
}
} else {
+
} else { ;knobs are going down
If (Knob3<Knob7) ;Knob3 is bellow knob7, knobs are spreading out
+
If averagePos<0 ;averageposition is bellow center
 
{
 
{
MouseClick,Left,ButtonX2,ButtonY
+
MouseClick,Left,ButtonX4,ButtonY
 
}
 
}
 
}
 
}
oldKnob3 := Knob3
+
oldKnob4 := Knob4
oldKnob7 := Knob7
+
oldKnob6 := Knob6
 
}
 
}
  
;~ Reverse Direction Sliders
+
 
If (Knob5<>oldKnob5) ;knob moved
+
If (Knob3<>oldKnob3) ;knob moved
 
{
 
{
 
NoKnobsMoved := False  
 
NoKnobsMoved := False  
If (Knob5>oldKnob5) ;knob rose
+
averagePos := floor((Knob3+Knob7)/2)
 +
If (Knob3>oldKnob3) ;knobs are going up
 
{
 
{
If (Knob5>Knob6) ;Knob5 is above Knob6, knobs are spreading out
+
If averagePos>0 ;averageposition is above center
 
{
 
{
MouseClick,Left,ButtonX5,ButtonY
+
MouseClick,Left,ButtonX2,ButtonY
 
}
 
}
} else {
+
} else { ;knobs are going down
If (Knob5<Knob6) ;Knob5 is bellow Knob6, knobs are spreading out
+
If averagePos<0 ;averageposition is bellow center
 
{
 
{
MouseClick,Left,ButtonX5,ButtonY
+
MouseClick,Left,ButtonX2,ButtonY
 
}
 
}
 
}
 
}
oldKnob5 := Knob5
+
oldKnob3 := Knob3
oldKnob6 := Knob6
+
oldKnob7 := Knob7
 
}
 
}
 
 
 
;~ ********************
 
;~ COMMENTED SECTION, USE THIS FOR DOUBLE SLIDERS THAT TRAVEL IN THE SAME DIRECTION
 
;~ ********************
 
;~ Same Direction Sliders
 
;~ If (Knob4<>oldKnob4) ;knob moved
 
;~ {
 
;~ NoKnobsMoved := False
 
;~ averagePos := floor((Knob4+Knob6)/2)
 
;~ If (Knob4>oldKnob4) ;knobs are going up
 
;~ {
 
;~ If averagePos>0 ;averageposition is above center
 
;~ {
 
;~ MouseClick,Left,ButtonX4,ButtonY
 
;~ }
 
;~ } else { ;knobs are going down
 
;~ If averagePos<0 ;averageposition is bellow center
 
;~ {
 
;~ MouseClick,Left,ButtonX4,ButtonY
 
;~ }
 
;~ }
 
;~ oldKnob4 := Knob4
 
;~ oldKnob6 := Knob6
 
;~ }
 
  
  
Line 205: Line 206:
  
 
;~ First Single Slider
 
;~ First Single Slider
If (Knob4>oldKnob4) ;knob Rose
+
If (Knob1>oldKnob1) ;knob Rose
 
{
 
{
 
NoKnobsMoved := False  
 
NoKnobsMoved := False  
oldKnob4 := Knob4
+
oldKnob1 := Knob1
If (Knob4>Axis4) ;knob Over Line
+
If (Knob1>Axis4) ;knob Over Line
 
{
 
{
 
MouseClick,Left,ButtonX1,ButtonY
 
MouseClick,Left,ButtonX1,ButtonY
 
}
 
}
 
} else {
 
} else {
If (Knob4<oldKnob4) ;knob Fell
+
If (Knob1<oldKnob1) ;knob Fell
 
{
 
{
 
NoKnobsMoved := False  
 
NoKnobsMoved := False  
oldKnob4 := Knob4
+
oldKnob1 := Knob1
If (Knob4<Axis4) ;knob Bellow Line
+
If (Knob1<Axis4) ;knob Bellow Line
 
{
 
{
 
MouseClick,Left,ButtonX1,ButtonY
 
MouseClick,Left,ButtonX1,ButtonY
Line 232: Line 233:
 
If Knob2>0 ;knob Over Line
 
If Knob2>0 ;knob Over Line
 
{
 
{
MouseClick,Left,ButtonX3,ButtonY
+
MouseClick,Left,ButtonX5,ButtonY
 
}
 
}
 
} else {
 
} else {
Line 241: Line 242:
 
If Knob2<0 ;knob Bellow Line
 
If Knob2<0 ;knob Bellow Line
 
{
 
{
MouseClick,Left,ButtonX3,ButtonY
+
MouseClick,Left,ButtonX5,ButtonY
 
}
 
}
 
}
 
}
Line 253: Line 254:
 
If Knob1>0 ;knob Over Line
 
If Knob1>0 ;knob Over Line
 
{
 
{
MouseClick,Left,ButtonX4,ButtonY
+
MouseClick,Left,ButtonX3,ButtonY
 
}
 
}
 
} else {
 
} else {
Line 262: Line 263:
 
If Knob1 < 0 ;knob Bellow Line
 
If Knob1 < 0 ;knob Bellow Line
 
{
 
{
MouseClick,Left,ButtonX4,ButtonY
+
MouseClick,Left,ButtonX3,ButtonY
 
}
 
}
 
}
 
}

Revision as of 22:35, 31 October 2010

;Ctrl+R to reload
;Ctrl+P to pause

;~ Info
WinActivate, eGenesis Client
WinGetActiveStats, win_Title, Xmax, Ymax, win_Xpos, win_Ypos
StartXGUI := Xmax+win_Xpos-255
StartYGUI := win_Ypos+35
Gui, +AlwaysOnTop +ToolWindow -Border +Background 
Gui, Add, Text,x10 y10,Crematory Macro Running
Gui, Add, Text,x10 y25,CTRL+R - Restart macro
Gui, Add, Text,x10 y40,CTRL+P - Pause macro
Gui, Add, Text,x10 y55 vMyText,CTRL+A - Turn ON Auto mode
Gui, Add, Text,x10 y75,Keep the crematory window away from popups.
Gui, Add, Button, x200 y5 gClose, Close 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window

gosub, Setup

WinActivate, eGenesis Client
lastTimeSlidersMoved := A_Now 
autoMode := false
Loop
{
	If (autoMode=true)
	{
;~ 		check if completed
		ImageSearch, BarX,BarY,ProgressSX,ProgressSY,ProgressEX,ProgressEY,*40 BitRed.png
		if ErrorLevel=1
		{
			;~ 	Knobs not moving - Finished
			gosub, unload
			gosub, load
		} else {
			currentTime := A_Now
			tempLast := LastTimeSlidersMoved
			EnvSub, tempLast,,Seconds 
			If (tempLast<-300)
			{
				gosub, unload
				gosub, load
			}
		}
	} 
	;~ 	Check to make sure the window wasn't moved
		WindowMoved := false 
		ImageSearch, NewLimeX,NewLimeY,0,0,Xmax,Ymax,*40 Lime.png
		If ErrorLevel<1
		{
			If (NewLimeX<>LimeX)
			{
				WindowMoved := true
			} else {
				If (NewLimeY<>LimeY)
				{
					WindowMoved := True
				}	
			}
			If WindowMoved=True
			{
				gosub, Setup
			}
		} else {
			gosub, Setup
		}	
		
			
		ImageSearch, KnobX,KnobY1,SliderSearchSX1,SliderSearchSY,SliderSearchEX1,SliderSearchEY,*40 SliderKnob.png	
		ImageSearch, KnobX,KnobY2,SliderSearchSX2,SliderSearchSY,SliderSearchEX2,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY3,SliderSearchSX3,SliderSearchSY,SliderSearchEX3,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY4,SliderSearchSX4,SliderSearchSY,SliderSearchEX4,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY5,SliderSearchSX5,SliderSearchSY,SliderSearchEX5,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY6,SliderSearchSX6,SliderSearchSY,SliderSearchEX6,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY7,SliderSearchSX7,SliderSearchSY,SliderSearchEX7,SliderSearchEY,*40 SliderKnob.png
		Knob1 := SliderM-KnobY1-1
		Knob2 := SliderM-KnobY2-1
		Knob3 := SliderM-KnobY3-1
		Knob4 := SliderM-KnobY4-1
		Knob5 := SliderM-KnobY5-1
		Knob6 := SliderM-KnobY6-1
		Knob7 := SliderM-KnobY7-1

		NoKnobsMoved := True

;~ 		Reverse Direction Sliders
;~ 		If (Knob3<>oldKnob3) ;knob moved
;~ 		{
;~ 			NoKnobsMoved := False 
;~ 			If (Knob3>oldKnob3) ;knob rose
;~ 			{
;~ 				If (Knob3>Knob7) ;Knob3 is above knob7, knobs are spreading out
;~ 				{
;~ 					MouseClick,Left,ButtonX2,ButtonY
;~ 				}
;~ 			} else {
;~ 				If (Knob3<Knob7) ;Knob3 is bellow knob7, knobs are spreading out
;~ 				{
;~ 					MouseClick,Left,ButtonX2,ButtonY
;~ 				}
;~ 			}
;~ 			oldKnob3 := Knob3
;~ 			oldKnob7 := Knob7
;~ 		}


;~ ********************
;~ 	COMMENTED SECTION, USE THIS FOR DOUBLE SLIDERS THAT TRAVEL IN THE SAME DIRECTION
;~ ********************
;~ 	Same Direction Sliders 
		If (Knob4<>oldKnob4) ;knob moved
		{
			NoKnobsMoved := False 
			averagePos := floor((Knob4+Knob6)/2)
			If (Knob4>oldKnob4) ;knobs are going up
			{
				If averagePos>0 ;averageposition is above center
				{
					MouseClick,Left,ButtonX4,ButtonY
				}
			} else { ;knobs are going down
				If averagePos<0 ;averageposition is bellow center
				{
					MouseClick,Left,ButtonX4,ButtonY
				}
			}
			oldKnob4 := Knob4
			oldKnob6 := Knob6
		}


		If (Knob3<>oldKnob3) ;knob moved
		{
			NoKnobsMoved := False 
			averagePos := floor((Knob3+Knob7)/2)
			If (Knob3>oldKnob3) ;knobs are going up
			{
				If averagePos>0 ;averageposition is above center
				{
					MouseClick,Left,ButtonX2,ButtonY
				}
			} else { ;knobs are going down
				If averagePos<0 ;averageposition is bellow center
				{
					MouseClick,Left,ButtonX2,ButtonY
				}
			}
			oldKnob3 := Knob3
			oldKnob7 := Knob7
		}



		NumAbove := 0
		NumBellow := 0
		If Knob3<0
		{
			NumBellow++
		} Else {
			NumAbove++
		}
		If Knob7<0
		{
			NumBellow++
		} Else {
			NumAbove++
		}
		If Knob5<0
		{
			NumBellow++
		} Else {
			NumAbove++
		}
		If Knob6<0
		{
			NumBellow++
		} Else {
			NumAbove++
		}

		Axis4 := 0
		Axis2 := 0
		If NumAbove=1
		{
			Axis4 := 5
		} else {
			If NumAbove=0
			{
				Axis4 := 5
				Axis2 := 5
			} else {
				If NumBellow=1
				{
					Axis4 := -5
				} else {
					If NumBellow=0
					{
						Axis4 := -5
						Axis2 := -5
					}
				}
			}
		}
		


	;~ 	First Single Slider
		If (Knob1>oldKnob1) ;knob Rose
		{
			NoKnobsMoved := False 
			oldKnob1 := Knob1
			If (Knob1>Axis4) ;knob Over Line
			{
				MouseClick,Left,ButtonX1,ButtonY
			}
		} else {
			If (Knob1<oldKnob1) ;knob Fell
			{
				NoKnobsMoved := False 
				oldKnob1 := Knob1
				If (Knob1<Axis4) ;knob Bellow Line
				{
					MouseClick,Left,ButtonX1,ButtonY
				}
			}
		}

	;~ 	Second Single Slider
		If (Knob2>oldKnob2) ;knob Rose
		{
			NoKnobsMoved := False 
			oldKnob2 := Knob2
			If Knob2>0 ;knob Over Line
			{
				MouseClick,Left,ButtonX5,ButtonY
			}
		} else {
			If (Knob2<oldKnob2) ;knob Fell
			{
				NoKnobsMoved := False 
				oldKnob2 := Knob2
				If Knob2<0 ;knob Bellow Line
				{
					MouseClick,Left,ButtonX5,ButtonY
				}
			}
		}

	;~ 	Third Single Slider
		If (Knob1>oldKnob1) ;knob Rose
		{
			NoKnobsMoved := False 
			oldKnob1 := Knob1
			If Knob1>0 ;knob Over Line
			{
				MouseClick,Left,ButtonX3,ButtonY
			}
		} else {
			If (Knob1<oldKnob1) ;knob Fell
			{
				NoKnobsMoved := False 
				oldKnob1 := Knob1
				If Knob1 < 0 ;knob Bellow Line
				{
					MouseClick,Left,ButtonX3,ButtonY
				}
			}
		}


	
}

Setup:
IfWinExist eGenesis Client
{
	WinGet, GameWinHandle, ID, eGenesis Client
} else {
	Msgbox, eGenesis client not running, exiting...
Exit
}

;~ Base
OriX := 625
OriY := 342

;~ Offsets
offRedLineStartX := OriX-625
offRedLineStartY := OriY-333
offSliderT := OriY-364
offSliderM := OriY-424
offSliderB := OriY-483
offSliderX1 := OriX-618
offSliderX2 := OriX-654
offSliderX3 := OriX-690
offSliderX4 := OriX-726
offSliderX5 := OriX-762
offSliderX6 := OriX-798
offSliderX7 := OriX-834
offButtonY := OriY-503
offButtonX1 := OriX-647
offButtonX2 := OriX-688
offButtonX3 := OriX-729
offButtonX4 := OriX-769
offButtonX5 := OriX-809


;~ Locate Word Lime
WinActivate eGenesis Client
ImageSearch, LimeX,LimeY,0,0,Xmax,Ymax,*40 Lime.png
If ErrorLevel=2
{
	MsgBox,,,Couldn't Find Lime.png
}
If ErrorLevel<1
{
	GuiControl, Text, Label, Found Crematory Window
} else {
	If ErrorLevel<2
	{
		;Didn't find the Word Lime
		MsgBox,,Crematory Macro,Crematory Window not Found, closing macro
		ExitApp
	}
}

RedLineStartX := LimeX-offRedLineStartX
RedLineStartY := LimeY-offRedLineStartY
SliderX1 := LimeX-offSliderX1
SliderX2 := LimeX-offSliderX2
SliderX3 := LimeX-offSliderX3
SliderX4 := LimeX-offSliderX4
SliderX5 := LimeX-offSliderX5
SliderX6 := LimeX-offSliderX6
SliderX7 := LimeX-offSliderX7
SliderT := LimeY-offSliderT
SliderM := LimeY-offSliderM
SliderB := LimeY-offSliderB
ButtonY := LimeY-offButtonY
ButtonX1 := LimeX-offButtonX1
ButtonX2 := LimeX-offButtonX2
ButtonX3 := LimeX-offButtonX3
ButtonX4 := LimeX-offButtonX4
ButtonX5 := LimeX-offButtonX5
ProgressSX := LimeX-2
ProgressSY := LimeY-12
ProgressEX := LimeX+3
ProgressEY := LimeY+5
SliderSearchSX1 := SliderX1-2
SliderSearchSX2 := SliderX2-2
SliderSearchSX3 := SliderX3-2
SliderSearchSX4 := SliderX4-2
SliderSearchSX5 := SliderX5-2
SliderSearchSX6 := SliderX6-2
SliderSearchSX7 := SliderX7-2
SliderSearchEX1 := SliderX1+7
SliderSearchEX2 := SliderX2+7
SliderSearchEX3 := SliderX3+7
SliderSearchEX4 := SliderX4+7
SliderSearchEX5 := SliderX5+7
SliderSearchEX6 := SliderX6+7
SliderSearchEX7 := SliderX7+7
SliderSearchSY := SliderT-10
SliderSearchEY := SliderB+10
oldKnob1 := 100
oldKnob2 := 100
oldKnob3 := 100
oldKnob4 := 100
oldKnob5 := 100
oldKnob6 := 100
oldKnob7 := 100
return

Unload: ;Unload
;~ 	Knobs not moving - Finished
;~ 	Refresh
	MouseClick,Left,LimeX,LimeY
	sleep, 100
;~ 	Find Take
	ImageSearch,LoadX,LoadY,LimeX-29,LimeY-136,LimeX+49,LimeY-40,*40 Take.png
	If ErrorLevel<1
	{
		MouseClick,Left,LoadX,LoadY
		sleep,300
		ImageSearch,EveX,EveY,LoadX,LoadY-50,LoadX+133,LoadY+50,*90 Everything.png
		If ErrorLevel<1
		{
			MouseClick,Left,EveX,EveY
			sleep, 300
		} 
	}
	return


Load:
;~ 	Knobs not moving - Finished
;~ 	Refresh
	MouseClick,Left,LimeX,LimeY
	sleep, 100
;~ 	Find Load
	ImageSearch,LoadX,LoadY,LimeX-29,LimeY-136,LimeX+49,LimeY-40,*40 Load.png
	If ErrorLevel<1
	{
		;load Limestone
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY-33
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Leeks
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY-17
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Flax
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Papyrus
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY+17
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Wood
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY+33
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;Fire
		MouseClick,Left,LoadX,LoadY-17
		sleep, 100
	}
	return

Close:
ExitApp

^a:: ;automode
if (autoMode=True)
{
	autoMode := False
	GuiControl,,myText,CTRL+A - Auto Mode is OFF
} else {
	autoMode := True
	GuiControl,,myText,CTRL+A - Auto Mode is ON
}
return

^p::pause
^r::reload