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:Zahariel Bastet/Crematory

From A Tale in the Desert
Jump to navigationJump to search
// This currently works for my screen resolution 1920x1200 with ATITD maximized
// Pin the crematory window in the upper left of the screen as far into the corner as possible
// Load with stuff manually and make sure the window is fully refreshed so that the 
// "fire crematory" button appears and there is no slider bar!

// Start the macro - it will click the fire button which will also bring ATITD to the top
// Once the crematory has finished the macro should stop within a few seconds. Probably.

// For different screen resolutions I guess use "pixie" or something similar to get coords
// Need to change slider and button numbers under slider control for your particular crematory
// (The wiki explains how to analyse your crematory)

//Zahariel's Crematory:
//Sliders numbered left-to-right 1-7.
//Buttons labeled left-to-right A-E.

//A -> 3
//B -> 2
//C -> 4, 6
//D -> 5
//E -> 1, 7

//(E B A C D C E)


	Constants 

		//Make sure the "Take..." option is NOT in the pinup menu or 
		//else this script will fail (burn your loaded resources).
		//Make sure the crematory is completely empty before 
		//pinning up the menu, in the upper left corner.

		//These settings will work in Windows 7 at 1920x1200. Only 
		//change these it you want it to work at a different resolution.


		// Vertical position of middle of slider bar
		midSlider = 264

		// Horizontal positions of seven slider bars
		hrzSlider1 = 30
		hrzSlider2 = 66
		hrzSlider3 = 102
		hrzSlider4 = 138
		hrzSlider5 = 174
		hrzSlider6 = 210
		hrzSlider7 = 246

		// Vertical position of button centres
		vrtButton = 343

		// Horizontal positions of five button centres
		hrzButtonA = 57
		hrzButtonB = 97
		hrzButtonC = 137
		hrzButtonD = 177
		hrzButtonE = 217


		// Position of left most point of red line
		hrzRed = 34
		verRed = 174



		//Leave these alone
		count = 0
		counthi = 0
		countlo = 0
		clickflag = 0
		flag = 1
		posSlider1 = 0
		posSlider2 = 0
		posSlider3 = 0
		posSlider4 = 0
		posSlider5 = 0
		posSlider6 = 0
		posSlider7 = 0
		comSlider1 = 0
		comSlider2 = 0
		posSlider1old = 100
		posSlider2old = 100
		posSlider3old = 100
		posSlider4old = 100
		posSlider5old = 100
		posSlider6old = 100
		posSlider7old = 100
		comSlider1old = 100
		comSlider2old = 100

	END


CommandDelay 1

// Clicks to fire the crematory (need to specify center of fire button)
mousepos 100, 84
delay 150
LeftClick


// First call to obtain initial positions of sliders
call GETSLIDERPOS
Compute posSlider1old = $posSlider1
Compute posSlider2old = $posSlider2
Compute posSlider3old = $posSlider3
Compute posSlider4old = $posSlider4
Compute posSlider5old = $posSlider5
Compute posSlider6old = $posSlider6
Compute posSlider7old = $posSlider7


loop 500

	//Credit to Daniels for this sniplet of code to watch the red progress bar
	//and exit script when the bar disappears (when done).

	// Checks whether the batch is done, breaks loop if so
	LoadRGB $hrzRed,$verRed
	delay 100
	if {RGBRed} < 250
		break
	END



	call GETSLIDERPOS

// One slider per button control
// Need to alter slider and button numbers for particular crematory


//1st single slider/button combo:

	if $posSlider3 > $posSlider3old
		mousepos $hrzButtonA,$vrtButton
		delay 150
		LeftClick
	END


//2nd single slider/button combo:

	if $posSlider2 > $posSlider2old
		mousepos $hrzButtonB,$vrtButton
		delay 150
		LeftClick
	END


//3rd single slider/button combo:

	if $posSlider5 > $posSlider5old
		mousepos $hrzButtonD,$vrtButton
		delay 150
		LeftClick
	END

// Two sliders per button control (use centre of mass, i.e. average)
// Need to alter slider and button numbers for particular crematory
//Note Editing a slider number is $posSlider#, not comSlider#. You should still have the numbers $comSlider1 and 2 below

//1st two slider/one button combo:
	Compute comSlider1 = (($posSlider4 * $posSlider4) + ($posSlider6 * $posSlider6))
	if $comSlider1 > $comSlider1old
		mousepos $hrzButtonC, $vrtButton
		delay 100
		LeftClick
	END





//2nd two slider/one button combo:

	Compute comSlider2 = (($posSlider1 * $posSlider1) + ($posSlider7 * $posSlider7))
	if $comSlider2 > $comSlider2old
		mousepos $hrzButtonE, $vrtButton
		delay 100
		LeftClick
	END



	Compute posSlider1old = $posSlider1
	Compute posSlider2old = $posSlider2
	Compute posSlider3old = $posSlider3
	Compute posSlider4old = $posSlider4
	Compute posSlider5old = $posSlider5
	Compute posSlider6old = $posSlider6
	Compute posSlider7old = $posSlider7
	Compute comSlider1old = $comSlider1
	Compute comSlider2old = $comSlider2

END

// Procedure to find slider positions

Procedure GETSLIDERPOS
	
	Compute counthi = $midSlider
	Compute countlo = $midSlider
	Compute flag = 1
	IsBlack $hrzSlider1, $midSlider
			Compute posSlider1 = 0
			Compute flag = 0
	END	
	while $flag > 0
		Compute counthi = $counthi + 4
		IsBlack $hrzSlider1, $counthi
			Loop 4
				IsBlack $hrzSlider1, $counthi
					Compute posSlider1 = $counthi - $midSlider
				END
				Compute counthi = $counthi - 1
			END
			Compute flag = 0
		END
		Compute countlo = $countlo - 4
		IsBlack $hrzSlider1, $countlo
			Loop 4
				IsBlack $hrzSlider1, $countlo
					Compute posSlider1 = $midSlider - $countlo
				END
				Compute countlo = $countlo + 1
			END
			Compute flag = 0
		END
	END

	Compute counthi = $midSlider
	Compute countlo = $midSlider
	Compute flag = 1
	IsBlack $hrzSlider2, $midSlider
			Compute posSlider2 = 0
			Compute flag = 0
	END	
	while $flag > 0
		Compute counthi = $counthi + 4
		IsBlack $hrzSlider2, $counthi
			Loop 4
				IsBlack $hrzSlider2, $counthi
					Compute posSlider2 = $counthi - $midSlider
				END
				Compute counthi = $counthi - 1
			END
			Compute flag = 0
		END
		Compute countlo = $countlo - 4
		IsBlack $hrzSlider2, $countlo
			Loop 4
				IsBlack $hrzSlider2, $countlo
					Compute posSlider2 = $midSlider - $countlo
				END
				Compute countlo = $countlo + 1
			END
			Compute flag = 0
		END
	END

	Compute counthi = $midSlider
	Compute countlo = $midSlider
	Compute flag = 1
	IsBlack $hrzSlider3, $midSlider
			Compute posSlider3 = 0
			Compute flag = 0
	END	
	while $flag > 0
		Compute counthi = $counthi + 4
		IsBlack $hrzSlider3, $counthi
			Loop 4
				IsBlack $hrzSlider3, $counthi
					Compute posSlider3 = $counthi - $midSlider
				END
				Compute counthi = $counthi - 1
			END
			Compute flag = 0
		END
		Compute countlo = $countlo - 4
		IsBlack $hrzSlider3, $countlo
			Loop 4
				IsBlack $hrzSlider3, $countlo
					Compute posSlider3 = $midSlider - $countlo
				END
				Compute countlo = $countlo + 1
			END
			Compute flag = 0
		END
	END

	Compute counthi = $midSlider
	Compute countlo = $midSlider
	Compute flag = 1
	IsBlack $hrzSlider4, $midSlider
			Compute posSlider4 = 0
			Compute flag = 0
	END	
	while $flag > 0
		Compute counthi = $counthi + 4
		IsBlack $hrzSlider4, $counthi
			Loop 4
				IsBlack $hrzSlider4, $counthi
					Compute posSlider4 = $counthi - $midSlider
				END
				Compute counthi = $counthi - 1
			END
			Compute flag = 0
		END
		Compute countlo = $countlo - 4
		IsBlack $hrzSlider4, $countlo
			Loop 4
				IsBlack $hrzSlider4, $countlo
					Compute posSlider4 = $midSlider - $countlo
				END
				Compute countlo = $countlo + 1
			END
			Compute flag = 0
		END
	END

	Compute counthi = $midSlider
	Compute countlo = $midSlider
	Compute flag = 1
	IsBlack $hrzSlider5, $midSlider
			Compute posSlider5 = 0
			Compute flag = 0
	END	
	while $flag > 0
		Compute counthi = $counthi + 4
		IsBlack $hrzSlider5, $counthi
			Loop 4
				IsBlack $hrzSlider5, $counthi
					Compute posSlider5 = $counthi - $midSlider
				END
				Compute counthi = $counthi - 1
			END
			Compute flag = 0
		END
		Compute countlo = $countlo - 4
		IsBlack $hrzSlider5, $countlo
			Loop 4
				IsBlack $hrzSlider5, $countlo
					Compute posSlider5 = $midSlider - $countlo
				END
				Compute countlo = $countlo + 1
			END
			Compute flag = 0
		END
	END

	Compute counthi = $midSlider
	Compute countlo = $midSlider
	Compute flag = 1
	IsBlack $hrzSlider6, $midSlider
			Compute posSlider6 = 0
			Compute flag = 0
	END	
	while $flag > 0
		Compute counthi = $counthi + 4
		IsBlack $hrzSlider6, $counthi
			Loop 4
				IsBlack $hrzSlider6, $counthi
					Compute posSlider6 = $counthi - $midSlider
				END
				Compute counthi = $counthi - 1
			END
			Compute flag = 0
		END
		Compute countlo = $countlo - 4
		IsBlack $hrzSlider6, $countlo
			Loop 4
				IsBlack $hrzSlider6, $countlo
					Compute posSlider6 = $midSlider - $countlo
				END
				Compute countlo = $countlo + 1
			END
			Compute flag = 0
		END
	END

	Compute counthi = $midSlider
	Compute countlo = $midSlider
	Compute flag = 1
	IsBlack $hrzSlider7, $midSlider
			Compute posSlider7 = 0
			Compute flag = 0
	END	
	while $flag > 0
		Compute counthi = $counthi + 4
		IsBlack $hrzSlider7, $counthi
			Loop 4
				IsBlack $hrzSlider7, $counthi
					Compute posSlider7 = $counthi - $midSlider
				END
				Compute counthi = $counthi - 1
			END
			Compute flag = 0
		END
		Compute countlo = $countlo - 4
		IsBlack $hrzSlider7, $countlo
			Loop 4
				IsBlack $hrzSlider7, $countlo
					Compute posSlider7 = $midSlider - $countlo
				END
				Compute countlo = $countlo + 1
			END
			Compute flag = 0
		END
	END

END