The Wiki for Tale 8 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:Augir/barley macro

From A Wiki in the Desert
Jump to navigation Jump to search

-- Barley Macro for Tale 7 by Talos. -- -- Thanks to veggies.lua for the build button locations

dofile("common.inc"); -- dofile("../lib/water.lua");

WARNING=[[ THIS IS A BETA MACRO YOU ARE USING AT YOUR OWN RISK

  • Plant where you stand FALSE
  • keep chats minimized or at right
  • F8f8f8 mode

]]

NUM_LOOPS = 100 -- NUM_WATERINGS = 4 -- NUM_WATERINGS = 2

NUM_WATERINGS = 3

CLICK_DELAY = 100

POS_X_START = 30 POS_Y_START = 80 GRID_ROWS = 3 BARLEY_WIDTH = 256 BARLEY_HEIGHT = 214

DEBUG = 0

-- -- Directions -- NORTH = {59, 51} EAST = {84, 74} SOUTH = {60, 98} WEST = {37, 75} N_EAST = {75, 62} N_WEST = {45, 60} S_EAST = {75, 91} S_WEST = {45, 87}

BUILD = {31, 135}

function setup() num_loops = NUM_LOOPS

-- Get screen size xyWindowSize = srGetWindowSize()

   xyWindowMiddle = {math.floor(xyWindowSize[0]/2), math.floor(xyWindowSize[1]/2)}
   lsPrintln("ScreenSize " .. xyWindowSize[0] .. "x" .. xyWindowSize[1])

lsPrintln("Middle Point (" .. xyWindowMiddle[1] .. "," .. xyWindowMiddle[2] .. ")")

-- Find Barle Button plantLocation = FindBarleyButton(); end

function doit() askForWindow(WARNING); setup(); clickAllImages("BarleyThisIs.png", 1, 1, 1) for i=1,NUM_LOOPS do doPlanting(i) end end


function doPlanting(round) statusScreen("(" .. round .. "/" .. NUM_LOOPS .. ") Planting "); drawWater(); statusScreen("Planting Grid (" .. round .. "/" .. NUM_LOOPS .. ")") plantGrid(); statusScreen("Arange Windows (" .. round .. "/" .. NUM_LOOPS .. ")") ArrangeWindows(); statusScreen("Tending Barleys") TendBarleys(); end

-- -- Plant a grid of Barley -- function plantGrid() baley_plant = 0 PlantBarleyAndPin(NORTH, 12 , 0, -250) PlantBarleyAndPin(WEST, 12 , -250, 0) PlantBarleyAndPin(EAST, 12 , 250, 0)

PlantBarleyAndPin(N_WEST, 12 , -300, -300) PlantBarleyAndPin(N_EAST, 12 , 300, -300) PlantBarleyAndPin(S_WEST, 12 , -300, 300) PlantBarleyAndPin(S_EAST, 12 , 300, 300)

PlantBarleyAndPin(NORTH, 0 , 50, 50)

PlantBarleyAndPin(N_WEST, 6 , -150, -150) PlantBarleyAndPin(N_EAST, 6 , 150, -150) PlantBarleyAndPin(S_WEST, 6 , -150, 150) PlantBarleyAndPin(S_EAST, 6 , 150, 150)

-- lsSleep(500) PlantBarleyAndPin(SOUTH, 12 , 0, 280) end

-- -- Find the plant barley button -- function FindBarleyButton() srReadScreen();

local imgBarley = "barley.png"; local xyPlantBarley = srFindImage(imgBarley); if not xyPlantBarley then error 'Could not find plant window'; end lsPrintln("Found Barley Button (" .. xyPlantBarley[0] .. "," .. xyPlantBarley[1] .. ")") return xyPlantBarley end

-- -- Plant some barley pin the menu and move to the corner -- function PlantBarleyAndPin(direction, steps, clickX, clickY) local posX = xyWindowMiddle[1] + clickX local posY = xyWindowMiddle[2] + clickY local drag_X_start = posX + BARLEY_WIDTH - 6 local drag_Y_start = posY + BARLEY_HEIGHT/2 -6

-- Step 1: Plant Barley at location LeftClick( plantLocation[0], plantLocation[1], BUILD[1], BUILD[2], "Click plant Button") for i=1,steps do safeClick( direction[1], direction[2], 0); end LeftClick(BUILD[1], BUILD[2], poxX, posY, "Finalize build") DebugPosClick(posX, posY, 100) -- DebugPosClick(posX, posY, 3000) LeftClick(posX, posY, posX+10, posY+10, "Bring barley menu")

-- drag to corner safeDrag(drag_X_start, drag_Y_start, xyWindowSize[0] - 6 , xyWindowSize[1] - 6 ,1)

	safeClick(xyWindowSize[0] - BARLEY_WIDTH + 5, xyWindowSize[1] - BARLEY_HEIGHT +5,  1)

-- Allow break checkBreak(); baley_plant = baley_plant + 1 end

-- -- Arrange Windows -- function ArrangeWindows() local drag_X_start = xyWindowSize[0] - BARLEY_WIDTH + 5 local drag_Y_start = xyWindowSize[1] - BARLEY_HEIGHT +5

for count =0,baley_plant-1 do local col = math.floor(count/GRID_ROWS) local row = count - col * GRID_ROWS lsPrintln("Nove No " .. count .. " at (" .. col .. "," .. row .. ")")

local drag_X_end = POS_X_START + col * ( BARLEY_WIDTH + 4) local drag_Y_end = POS_Y_START + row * ( BARLEY_HEIGHT + 4) safeDrag(drag_X_start,drag_Y_start,drag_X_end,drag_Y_end,0)

-- Allow break checkBreak(); end end

-- -- Tend Barleys -- function TendBarleys() -- Add 2 Water and 1 fertilizer lsPrintln("+ Add 2 Water and Fertilizer") clickAllImages("BarleyWater.png", 200, 5) clickAllImages("BarleyFertlizer.png", 200, 5) LongWait(3) checkBreak(); clickAllImages("BarleyWater.png", 200, 5) LongWait(10)

for count =0,NUM_WATERINGS do checkBreak(); -- Add 1 Water lsPrintln("+ Add 1 Water") clickAllImages("BarleyWater.png", 200, 5) LongWait(12) end

LongWait(12) lsPrintln("+ Haervest") clickAllImages("BarleyHarvest.png", 1, 1) checkBreak(); lsSleep(100) clickAllImages("BarleyThisIs.png", 1, 1, 1) end


-- -- Helpers -- function ClickHelper(rightClick,x,y,watch_pt_x, watch_pt_y, debug_msg) if DEBUG then if watch_pt_x and watch_pt_y then lsPrintln(debug_msg .. " at (" .. x .. "," .. y .. ") using watcher (" .. watch_pt_x .. "," .. watch_pt_y .. ")") else lsPrintln(debug_msg .. " at (" .. x .. "," .. y .. ")") end end

if watch_pt_x and watch_pt_y then spot = getWaitSpot( watch_pt_x, watch_pt_y) end

safeBegin(); srClickMouseNoMove(x, y, rightClick); -- srClickMouse(x, y, rightClick);

if watch_pt_x and watch_pt_y then srReadScreen() ret = waitForChange(spot, CLICK_DELAY) end end

function RightClick(x,y, watch_pt_x, watch_pt_y, debug_msg) if not debug_msg then debug_msg = "Right Click" end ClickHelper(1, x, y, watch_pt_x, watch_pt_y, debug_msg) end

function LeftClick(x,y, debug_msg, watch_pt_x, watch_pt_y, debug_msg) if not debug_msg then debug_msg = "Left Click" end ClickHelper(0, x, y, watch_pt_x, watch_pt_y, debug_msg) end

function DebugPosClick( x, y, wait ) if not wait then wait = 1000 end lsPrintln("** DEBUG MOVE at (" .. x .. "," .. y .. ")") srSetMousePos(x,y) lsSleep(wait) end

function LongWait(secs) for i=0,secs do lsSleep(1000) checkBreak(); end end