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:Daniels/Macros/Crematory

From A Tale in the Desert
< User:Daniels
Revision as of 05:48, 25 January 2010 by Daniels (talk | contribs)
Jump to navigationJump to search
// Altered by Daniels to include a break when the crematory finishes, updated coords for 
// 1280x1024 (Vista), and an experimental "ExtraDelay" to try to handle extreme highs and lows.
//
// This currently works for my screen resolution 1280:1024 with ATITD in full screen
// 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 go back to ACTOOL and stop the macro - it currently just 
// has a huge crude loop - it would be relatively easy to monitor the progress bar but I 
// haven't done that yet

// 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)


	Constants 
		count = 0
		counthi = 0
		countlo = 0
		clickflag = 0
		flag = 1
		ExtraDelay = 0000
		posSlider1 = 0
		posSlider2 = 0
		posSlider3 = 0
		posSlider4 = 0
		posSlider5 = 0
		posSlider6 = 0
		posSlider7 = 0
		comSlider1 = 0
		comSlider2 = 0
		posSlider1old = 0
		posSlider2old = 0
		posSlider3old = 0
		posSlider4old = 0
		posSlider5old = 0
		posSlider6old = 0
		posSlider7old = 0
		// Vertical position of middle of slider bar
		midSlider = 271
		// Horizontal positions of seven slider bars
		hrzSlider1 = 37
		hrzSlider2 = 73
		hrzSlider3 = 109
		hrzSlider4 = 145
		hrzSlider5 = 181
		hrzSlider6 = 217
		hrzSlider7 = 253
		// Verticle position of slider bar top and bottom
		verSliderTop = 214
		verSliderTBottom = 328 		
		// Vertical position of button centres
		vrtButton = 350
		// Horizontal positions of five button centres
		hrzButton1 = 65
		hrzButton2 = 105
		hrzButton3 = 145
		hrzButton4 = 185
		hrzButton5 = 225
		// Position of leftmost point of red line
		hrzRed = 43
		verRed = 181
	END

// Clicks to fire the crematory (need to specify centre of fire button)
mousepos 125, 90
delay 100
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 250
	
	// 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

	if $posSlider1 > 0
		if $posSlider1 > $posSlider1old
			mousepos $hrzButton1,$vrtButton
			delay 100
			LeftClick
			if $posSlider1 > 47
				delay $ExtraDelay
			End
		END
	END
	if $posSlider1 < 0
		if $posSlider1 < $posSlider1old
			mousepos $hrzButton1,$vrtButton
			delay 100
			LeftClick
			if $posSlider1 < -47
				delay $ExtraDelay
			END
		END
	END

	if $posSlider2 > 0
		if $posSlider2 > $posSlider2old
			mousepos $hrzButton3,$vrtButton
			delay 100
			LeftClick
			if $posSlider2 > 47
				delay $ExtraDelay
			END
		END
	END
	if $posSlider2 < 0
		if $posSlider2 < $posSlider2old
			mousepos $hrzButton3,$vrtButton
			delay 100
			LeftClick
			if $posSlider2 < -47
				delay $ExtraDelay
			END
		END
	END

	if $posSlider4 > 0
		if $posSlider4 > $posSlider4old
			mousepos $hrzButton5,$vrtButton
			delay 100
			LeftClick
			if $posSlider4 > 47
				delay $ExtraDelay
			END
		END
	END
	if $posSlider4 < 0
		if $posSlider4 < $posSlider4old
			mousepos $hrzButton5,$vrtButton
			delay 100
			LeftClick
			if $posSlider4 < -47
				delay $ExtraDelay
			END
		END
	END

// Two sliders per button control (use centre of mass, i.e. average)
// Need to alter slider and button numbers for particular crematory

	Compute comSlider1 = ($posSlider5 + $posSlider6)/2
	if $comSlider1 > 0
		Compute clickflag = 0
		if $posSlider5 > $posSlider5old
			Compute clickflag = 1
		END
		if $posSlider6 > $posSlider6old
			Compute clickflag = 1
		END
		if $clickflag = 1
			mousepos $hrzButton2,$vrtButton
			delay 100
			LeftClick
			if $posSlider5 > 47
				delay $ExtraDelay
			END
			if $posSlider6 > 47
				delay $ExtraDelay
			END
		END
	END
	if $comSlider1 < 0
		Compute clickflag = 0
		if $posSlider5 < $posSlider5old
			Compute clickflag = 1
		END
		if $posSlider6 < $posSlider6old
			Compute clickflag = 1
		END
		if $clickflag = 1
			mousepos $hrzButton2,$vrtButton
			delay 100
			LeftClick
			if $posSlider5 < -47
				delay $ExtraDelay
			END
			if $posSlider6 < -47
				delay $ExtraDelay
			END
		END
	END

	Compute comSlider2 = ($posSlider3 + $posSlider7)/2
	if $comSlider2 > 0
		Compute clickflag = 0
		if $posSlider3 > $posSlider3old
			Compute clickflag = 1
		END
		if $posSlider7 > $posSlider7old
			Compute clickflag = 1
		END
		if $clickflag = 1
			mousepos $hrzButton4,$vrtButton
			delay 100
			LeftClick
			if $posSlider3 > 47
				delay $ExtraDelay
			END
			if $posSlider7 > 47
				delay $ExtraDelay
			END
		END
	END
	if $comSlider2 < 0
		Compute clickflag = 0
		if $posSlider3 < $posSlider3old
			Compute clickflag = 1
		END
		if $posSlider7 < $posSlider7old
			Compute clickflag = 1
		END
		if $clickflag = 1
			mousepos $hrzButton4,$vrtButton
			delay 100
			LeftClick
			if $posSlider3 < -47
				delay $ExtraDelay
			END
			if $posSlider7 < -47
				delay $ExtraDelay
			END
		END
	END


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

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 + 6
		IsBlack $hrzSlider1, $counthi
			Compute posSlider1 = $midSlider - $counthi
			Compute flag = 0
		END
		Compute countlo = $countlo - 6
		IsBlack $hrzSlider1, $countlo
			Compute posSlider1 = $midSlider - $countlo
			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 + 6
		IsBlack $hrzSlider2, $counthi
			Compute posSlider2 = $midSlider - $counthi
			Compute flag = 0
		END
		Compute countlo = $countlo - 6
		IsBlack $hrzSlider2, $countlo
			Compute posSlider2 = $midSlider - $countlo
			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 + 6
		IsBlack $hrzSlider3, $counthi
			Compute posSlider3 = $midSlider - $counthi
			Compute flag = 0
		END
		Compute countlo = $countlo - 6
		IsBlack $hrzSlider3, $countlo
			Compute posSlider3 = $midSlider - $countlo
			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 + 6
		IsBlack $hrzSlider4, $counthi
			Compute posSlider4 = $midSlider - $counthi
			Compute flag = 0
		END
		Compute countlo = $countlo - 6
		IsBlack $hrzSlider4, $countlo
			Compute posSlider4 = $midSlider - $countlo
			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 + 6
		IsBlack $hrzSlider5, $counthi
			Compute posSlider5 = $midSlider - $counthi
			Compute flag = 0
		END
		Compute countlo = $countlo - 6
		IsBlack $hrzSlider5, $countlo
			Compute posSlider5 = $midSlider - $countlo
			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 + 6
		IsBlack $hrzSlider6, $counthi
			Compute posSlider6 = $midSlider - $counthi
			Compute flag = 0
		END
		Compute countlo = $countlo - 6
		IsBlack $hrzSlider6, $countlo
			Compute posSlider6 = $midSlider - $countlo
			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 + 6
		IsBlack $hrzSlider7, $counthi
			Compute posSlider7 = $midSlider - $counthi
			Compute flag = 0
		END
		Compute countlo = $countlo - 6
		IsBlack $hrzSlider7, $countlo
			Compute posSlider7 = $midSlider - $countlo
			Compute flag = 0
		END
	END

END