<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://atitd.wiki/tale8/w/index.php?action=history&amp;feed=atom&amp;title=User%3AAugir%2Fbarley_macro</id>
	<title>User:Augir/barley macro - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://atitd.wiki/tale8/w/index.php?action=history&amp;feed=atom&amp;title=User%3AAugir%2Fbarley_macro"/>
	<link rel="alternate" type="text/html" href="https://atitd.wiki/tale8/w/index.php?title=User:Augir/barley_macro&amp;action=history"/>
	<updated>2026-04-19T21:14:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>https://atitd.wiki/tale8/w/index.php?title=User:Augir/barley_macro&amp;diff=21953&amp;oldid=prev</id>
		<title>Augir: Created page with &quot;-- Barley Macro for Tale 7 by Talos. -- -- Thanks to veggies.lua for the build button locations  dofile(&quot;common.inc&quot;); -- dofile(&quot;../lib/water.lua&quot;);  WARNING= THIS IS A BET...&quot;</title>
		<link rel="alternate" type="text/html" href="https://atitd.wiki/tale8/w/index.php?title=User:Augir/barley_macro&amp;diff=21953&amp;oldid=prev"/>
		<updated>2018-05-01T20:57:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;-- Barley Macro for Tale 7 by Talos. -- -- Thanks to veggies.lua for the build button locations  dofile(&amp;quot;common.inc&amp;quot;); -- dofile(&amp;quot;../lib/water.lua&amp;quot;);  WARNING= THIS IS A BET...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Barley Macro for Tale 7 by Talos.&lt;br /&gt;
--&lt;br /&gt;
-- Thanks to veggies.lua for the build button locations&lt;br /&gt;
&lt;br /&gt;
dofile(&amp;quot;common.inc&amp;quot;);&lt;br /&gt;
-- dofile(&amp;quot;../lib/water.lua&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
WARNING=[[&lt;br /&gt;
THIS IS A BETA MACRO YOU ARE USING AT YOUR OWN RISK&lt;br /&gt;
* Plant where you stand FALSE&lt;br /&gt;
* keep chats minimized or at right&lt;br /&gt;
* F8f8f8 mode&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
NUM_LOOPS = 100&lt;br /&gt;
-- NUM_WATERINGS = 4&lt;br /&gt;
-- NUM_WATERINGS = 2&lt;br /&gt;
&lt;br /&gt;
NUM_WATERINGS = 3&lt;br /&gt;
&lt;br /&gt;
CLICK_DELAY = 100&lt;br /&gt;
&lt;br /&gt;
POS_X_START = 30&lt;br /&gt;
POS_Y_START = 80&lt;br /&gt;
GRID_ROWS = 3&lt;br /&gt;
BARLEY_WIDTH = 256&lt;br /&gt;
BARLEY_HEIGHT = 214&lt;br /&gt;
&lt;br /&gt;
DEBUG = 0&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- Directions&lt;br /&gt;
--&lt;br /&gt;
NORTH  = {59, 51}&lt;br /&gt;
EAST   = {84, 74}&lt;br /&gt;
SOUTH  = {60, 98}&lt;br /&gt;
WEST   = {37, 75}&lt;br /&gt;
N_EAST = {75, 62}&lt;br /&gt;
N_WEST = {45, 60}&lt;br /&gt;
S_EAST = {75, 91}&lt;br /&gt;
S_WEST = {45, 87}&lt;br /&gt;
&lt;br /&gt;
BUILD = {31, 135}&lt;br /&gt;
&lt;br /&gt;
function setup()&lt;br /&gt;
	num_loops = NUM_LOOPS&lt;br /&gt;
&lt;br /&gt;
	-- Get screen size&lt;br /&gt;
	xyWindowSize = srGetWindowSize()&lt;br /&gt;
    xyWindowMiddle = {math.floor(xyWindowSize[0]/2), math.floor(xyWindowSize[1]/2)}&lt;br /&gt;
    lsPrintln(&amp;quot;ScreenSize &amp;quot; .. xyWindowSize[0] .. &amp;quot;x&amp;quot; .. xyWindowSize[1])&lt;br /&gt;
	lsPrintln(&amp;quot;Middle Point (&amp;quot; .. xyWindowMiddle[1] .. &amp;quot;,&amp;quot; .. xyWindowMiddle[2] .. &amp;quot;)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- Find Barle Button&lt;br /&gt;
	plantLocation = FindBarleyButton();&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function doit()&lt;br /&gt;
	askForWindow(WARNING);&lt;br /&gt;
	setup();&lt;br /&gt;
	clickAllImages(&amp;quot;BarleyThisIs.png&amp;quot;, 1, 1, 1)	&lt;br /&gt;
	for i=1,NUM_LOOPS do&lt;br /&gt;
		doPlanting(i)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function doPlanting(round)&lt;br /&gt;
	statusScreen(&amp;quot;(&amp;quot; .. round .. &amp;quot;/&amp;quot; .. NUM_LOOPS .. &amp;quot;) Planting &amp;quot;);&lt;br /&gt;
	drawWater();&lt;br /&gt;
	statusScreen(&amp;quot;Planting Grid (&amp;quot; .. round .. &amp;quot;/&amp;quot; .. NUM_LOOPS .. &amp;quot;)&amp;quot;)&lt;br /&gt;
	plantGrid();&lt;br /&gt;
	statusScreen(&amp;quot;Arange Windows (&amp;quot; .. round .. &amp;quot;/&amp;quot; .. NUM_LOOPS .. &amp;quot;)&amp;quot;)&lt;br /&gt;
	ArrangeWindows();&lt;br /&gt;
	statusScreen(&amp;quot;Tending Barleys&amp;quot;)&lt;br /&gt;
	TendBarleys();	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- Plant a grid of Barley&lt;br /&gt;
--&lt;br /&gt;
function plantGrid()&lt;br /&gt;
	baley_plant = 0&lt;br /&gt;
	PlantBarleyAndPin(NORTH,  12 ,    0, -250)&lt;br /&gt;
	PlantBarleyAndPin(WEST,   12 , -250,    0)&lt;br /&gt;
	PlantBarleyAndPin(EAST,   12 ,  250,    0)&lt;br /&gt;
	&lt;br /&gt;
	PlantBarleyAndPin(N_WEST, 12 , -300, -300)&lt;br /&gt;
	PlantBarleyAndPin(N_EAST, 12 ,  300, -300)&lt;br /&gt;
	PlantBarleyAndPin(S_WEST, 12 , -300,  300)&lt;br /&gt;
	PlantBarleyAndPin(S_EAST, 12 ,  300,  300)&lt;br /&gt;
	&lt;br /&gt;
	PlantBarleyAndPin(NORTH,  0  ,   50,   50)&lt;br /&gt;
&lt;br /&gt;
	PlantBarleyAndPin(N_WEST, 6 , -150, -150)&lt;br /&gt;
	PlantBarleyAndPin(N_EAST, 6 ,  150, -150)&lt;br /&gt;
	PlantBarleyAndPin(S_WEST, 6 , -150,  150)&lt;br /&gt;
	PlantBarleyAndPin(S_EAST, 6 ,  150,  150)&lt;br /&gt;
	&lt;br /&gt;
	-- lsSleep(500)&lt;br /&gt;
	PlantBarleyAndPin(SOUTH,  12 ,    0,  280)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- Find the plant barley button		&lt;br /&gt;
--&lt;br /&gt;
function FindBarleyButton()&lt;br /&gt;
	srReadScreen();&lt;br /&gt;
&lt;br /&gt;
	local imgBarley = &amp;quot;barley.png&amp;quot;;&lt;br /&gt;
	local xyPlantBarley = srFindImage(imgBarley);&lt;br /&gt;
	if not xyPlantBarley then&lt;br /&gt;
		error 'Could not find plant window';&lt;br /&gt;
	end&lt;br /&gt;
	lsPrintln(&amp;quot;Found Barley Button (&amp;quot; .. xyPlantBarley[0] .. &amp;quot;,&amp;quot; ..  xyPlantBarley[1] .. &amp;quot;)&amp;quot;)&lt;br /&gt;
	return xyPlantBarley&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- Plant some barley pin the menu and move to the corner		&lt;br /&gt;
--&lt;br /&gt;
function PlantBarleyAndPin(direction, steps, clickX, clickY)&lt;br /&gt;
	local posX = xyWindowMiddle[1] + clickX&lt;br /&gt;
	local posY = xyWindowMiddle[2] + clickY&lt;br /&gt;
	local drag_X_start = posX + BARLEY_WIDTH  - 6&lt;br /&gt;
	local drag_Y_start = posY + BARLEY_HEIGHT/2 -6&lt;br /&gt;
&lt;br /&gt;
	-- Step 1: Plant Barley at location&lt;br /&gt;
	LeftClick( plantLocation[0], plantLocation[1], BUILD[1], BUILD[2], &amp;quot;Click plant Button&amp;quot;)&lt;br /&gt;
	for i=1,steps do&lt;br /&gt;
		safeClick( direction[1], direction[2], 0);&lt;br /&gt;
	end&lt;br /&gt;
	LeftClick(BUILD[1], BUILD[2], poxX, posY, &amp;quot;Finalize build&amp;quot;)&lt;br /&gt;
	DebugPosClick(posX, posY, 100)&lt;br /&gt;
	-- DebugPosClick(posX, posY, 3000)&lt;br /&gt;
	LeftClick(posX, posY, posX+10, posY+10, &amp;quot;Bring barley menu&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- drag to corner&lt;br /&gt;
	safeDrag(drag_X_start,  drag_Y_start, xyWindowSize[0] - 6 ,  xyWindowSize[1] - 6  ,1)&lt;br /&gt;
 	safeClick(xyWindowSize[0] - BARLEY_WIDTH + 5, xyWindowSize[1] - BARLEY_HEIGHT +5,  1)&lt;br /&gt;
&lt;br /&gt;
	-- Allow break&lt;br /&gt;
	checkBreak();&lt;br /&gt;
	baley_plant = baley_plant  + 1&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- Arrange Windows		&lt;br /&gt;
--&lt;br /&gt;
function ArrangeWindows()&lt;br /&gt;
	local drag_X_start = xyWindowSize[0] - BARLEY_WIDTH + 5&lt;br /&gt;
	local drag_Y_start = xyWindowSize[1] - BARLEY_HEIGHT +5&lt;br /&gt;
	&lt;br /&gt;
	for count =0,baley_plant-1 do&lt;br /&gt;
		local col = math.floor(count/GRID_ROWS)&lt;br /&gt;
		local row = count - col * GRID_ROWS&lt;br /&gt;
		lsPrintln(&amp;quot;Nove No &amp;quot; .. count .. &amp;quot; at (&amp;quot; .. col .. &amp;quot;,&amp;quot; .. row .. &amp;quot;)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
		local drag_X_end = POS_X_START + col * ( BARLEY_WIDTH  + 4)&lt;br /&gt;
	    local drag_Y_end = POS_Y_START + row * ( BARLEY_HEIGHT + 4)&lt;br /&gt;
	    safeDrag(drag_X_start,drag_Y_start,drag_X_end,drag_Y_end,0)&lt;br /&gt;
&lt;br /&gt;
	    -- Allow break&lt;br /&gt;
		checkBreak();&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- Tend Barleys		&lt;br /&gt;
--&lt;br /&gt;
function TendBarleys()&lt;br /&gt;
	-- Add 2 Water and 1 fertilizer&lt;br /&gt;
	lsPrintln(&amp;quot;+ Add 2 Water and Fertilizer&amp;quot;)&lt;br /&gt;
	clickAllImages(&amp;quot;BarleyWater.png&amp;quot;, 200, 5)&lt;br /&gt;
	clickAllImages(&amp;quot;BarleyFertlizer.png&amp;quot;, 200, 5)&lt;br /&gt;
	LongWait(3)&lt;br /&gt;
	checkBreak();&lt;br /&gt;
	clickAllImages(&amp;quot;BarleyWater.png&amp;quot;, 200, 5)&lt;br /&gt;
	LongWait(10)&lt;br /&gt;
&lt;br /&gt;
	for count =0,NUM_WATERINGS do&lt;br /&gt;
		checkBreak();&lt;br /&gt;
		-- Add 1 Water&lt;br /&gt;
		lsPrintln(&amp;quot;+ Add 1 Water&amp;quot;)&lt;br /&gt;
		clickAllImages(&amp;quot;BarleyWater.png&amp;quot;, 200, 5)&lt;br /&gt;
		LongWait(12)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	LongWait(12)&lt;br /&gt;
	lsPrintln(&amp;quot;+ Haervest&amp;quot;)&lt;br /&gt;
	clickAllImages(&amp;quot;BarleyHarvest.png&amp;quot;, 1, 1)&lt;br /&gt;
	checkBreak();	&lt;br /&gt;
	lsSleep(100)&lt;br /&gt;
	clickAllImages(&amp;quot;BarleyThisIs.png&amp;quot;, 1, 1, 1)	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- Helpers&lt;br /&gt;
--&lt;br /&gt;
function ClickHelper(rightClick,x,y,watch_pt_x, watch_pt_y, debug_msg)&lt;br /&gt;
	if DEBUG then&lt;br /&gt;
		if watch_pt_x and watch_pt_y then&lt;br /&gt;
			lsPrintln(debug_msg .. &amp;quot; at (&amp;quot; .. x .. &amp;quot;,&amp;quot; .. y .. &amp;quot;) using watcher (&amp;quot; .. watch_pt_x .. &amp;quot;,&amp;quot; .. watch_pt_y .. &amp;quot;)&amp;quot;)&lt;br /&gt;
		else&lt;br /&gt;
			lsPrintln(debug_msg .. &amp;quot; at (&amp;quot; .. x .. &amp;quot;,&amp;quot; .. y .. &amp;quot;)&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if watch_pt_x and watch_pt_y then&lt;br /&gt;
		spot = getWaitSpot( watch_pt_x, watch_pt_y)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	safeBegin();&lt;br /&gt;
	srClickMouseNoMove(x, y, rightClick);&lt;br /&gt;
	-- srClickMouse(x, y, rightClick);&lt;br /&gt;
&lt;br /&gt;
	if watch_pt_x and watch_pt_y then&lt;br /&gt;
		 srReadScreen()&lt;br /&gt;
		 ret = waitForChange(spot, CLICK_DELAY)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function RightClick(x,y, watch_pt_x, watch_pt_y, debug_msg)&lt;br /&gt;
	if not debug_msg then&lt;br /&gt;
		debug_msg = &amp;quot;Right Click&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	ClickHelper(1, x, y, watch_pt_x, watch_pt_y, debug_msg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function LeftClick(x,y, debug_msg, watch_pt_x, watch_pt_y, debug_msg)&lt;br /&gt;
	if not debug_msg then&lt;br /&gt;
		debug_msg = &amp;quot;Left Click&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	ClickHelper(0, x, y, watch_pt_x, watch_pt_y, debug_msg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function DebugPosClick( x, y, wait )&lt;br /&gt;
	if not wait then&lt;br /&gt;
		wait = 1000&lt;br /&gt;
	end&lt;br /&gt;
	lsPrintln(&amp;quot;** DEBUG MOVE at (&amp;quot; .. x .. &amp;quot;,&amp;quot; .. y .. &amp;quot;)&amp;quot;)&lt;br /&gt;
	srSetMousePos(x,y)&lt;br /&gt;
	lsSleep(wait)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function LongWait(secs)&lt;br /&gt;
	for i=0,secs do&lt;br /&gt;
		lsSleep(1000)&lt;br /&gt;
		checkBreak();&lt;br /&gt;
	end&lt;br /&gt;
end&lt;/div&gt;</summary>
		<author><name>Augir</name></author>
	</entry>
</feed>