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.

Difference between revisions of "User:Atlas"

From A Wiki in the Desert
Jump to navigation Jump to search
m
Line 20: Line 20:
 
|}
 
|}
  
 +
 
dofile("screen_reader_common.inc");
 
dofile("screen_reader_common.inc");
 
dofile("ui_utils.inc");
 
dofile("ui_utils.inc");

Revision as of 20:47, 17 March 2018

Size/Color Small Medium Large Huge
1 2 3 4 5 6 7 1 2 3 4 1 2 1
Aqua X X X X X X X X X X O X X X
Beige O X X X X X X X O X X X O X
Black X X O X X X X X X X X O X X
Coral X X X O X X X X X O X X X X
Pink X X X X X O X - X X X X X X
Smoke X O X X O X O X X X X X X X
White X X X X X X X X X X X X X O


dofile("screen_reader_common.inc"); dofile("ui_utils.inc"); dofile("common.inc"); dofile("serialize.inc"); dofile("settings.inc"); dofile("constants.inc");

local GridAcross = 5; local DelayBeforePlanting = 100; local DelayMoving = 300; local DelayAfterPlanting = 500; local WindowAcross = 282; --How far across for each window local WindowDown = 145; --How far down for each window local MousePos xyCenter = {}; local EndMessage = " \n\nTo stop the macro, press Ctrl + Shift. To pause the macro, press Alt + Shift.";

askText = singleLine([[

Pin open the window with the desired seed, hover the mouse over the button, then press Shift to start the Macro.

]]);


function doit()

-- mousePos is location of Seed Plant, obtained when you start the macro
mousePos = askForWindow(askText);
initGlobals();
MainPlanter();

local RepeatTimes = 3 
-- Sinai Sage(w), Sunset Pond(w), Old Egypt, Nile Green(w) = 2
-- Old Dog(w2), Symphony Ridge = 3
-- Constitution Peak(w) = 4
-- Jacob's Field = 6

for i = 1, (RepeatTimes+1) do
   BedWatch2();
end

end

function initGlobals()

 srReadScreen();
 xyWindowSize = srGetWindowSize();

 xyCenter[0] = xyWindowSize[0] / 2 - 14;
 xyCenter[1] = xyWindowSize[1] / 2 + 18;
end

function BedWatch2()
  local WindowCount = clickAllImages("ThisIs.png");
  local WeedProgress = "Found " .. WindowCount .. " Flax Beds to tender. \n\n ";
  
      local intDown = 0;
      for intDown= 1, 3 do
              local intAcross = 0;
              for intAcross=1, GridAcross do
                      local windowstate=0;
                      while windowstate < 2 do
                              srReadScreen();
                              
                              local AcrossStart = (intAcross - 1) * WindowAcross;
                              local AcrossEnd = (intAcross * WindowAcross)- 50;
                              local DownStart = (intDown * WindowDown) - 75;
                              local DownEnd = (intDown * WindowDown) + 50;
                              
                              foundwindow = srFindImageInRange("ThisIs.png",AcrossStart,DownStart,AcrossEnd,DownEnd)
                              if foundwindow then
                                      --found window, now find state:
                                      srClickMouse(foundwindow[0],foundwindow[1]);
                                      sleepWithStatus(250, WeedProgress .. "(" .. intAcross .. ", " .. intDown .. ")\nWait Window\n" .. EndMessage);
                                      srReadScreen();
                                      
                                      foundWait = srFindImageInRange("Nothing.png",AcrossStart,DownStart,AcrossEnd,DownEnd)
                                      foundWeed = srFindImageInRange("Weed.png",AcrossStart,DownStart,AcrossEnd,DownEnd)
                                      foundSeeds = srFindImageInRange("HarvestSeeds.png",AcrossStart,DownStart,AcrossEnd,DownEnd)
                                      foundHarvest = srFindImageInRange("HarvestThisFlax.png",AcrossStart,DownStart,AcrossEnd,DownEnd)
                                      if foundWait then
                                              windowstate=1;
                                              sleepWithStatus(500, WeedProgress .. "(" .. intAcross .. ", " .. intDown .. ")\nWait Window\n" .. EndMessage);
                                      end
                                      if foundWeed then
                                              windowstate=2;
                                              srClickMouse(foundWeed[0]+10,foundWeed[1]+5); 
                                              sleepWithStatus(500, WeedProgress .. "(" .. intAcross .. ", " .. intDown .. ")\nWeeding\n" .. EndMessage);
                                      end
                                      if foundSeeds then
                                              windowstate=2;
                                              srClickMouse(foundSeeds[0]+10,foundSeeds[1]+5);
                                              sleepWithStatus(500, WeedProgress .. "(" .. intAcross .. ", " .. intDown .. ")\nDeseeding\n" .. EndMessage);
                                      end
                                      if foundHarvest then
                                              windowstate=2;
                                              srClickMouse(foundHarvest[0]+10,foundHarvest[1]+5);  --Harvest
                                              sleepWithStatus(500, WeedProgress .. "(" .. intAcross .. ", " .. intDown .. ")\nHarvesting\n" .. EndMessage);
                                              srClickMouse(foundwindow[0],foundwindow[1],1); --Right click to Close window
                                              sleepWithStatus(500, WeedProgress .. "(" .. intAcross .. ", " .. intDown .. ")\nHarvesting\n" .. EndMessage);
                                      end
                              else
                                      error("Could not find window (" .. intAcross .. ", " .. intDown .. ") therefore aborting program.");
                              end
                      end
              end
      
          local WindowCount = clickAllImages("ThisIs.png");
      end

end

function MainPlanter()

      for i=1, (GridAcross - 1) do
              PlantSeed(i,1);
              Move(VK_LEFT);
      end
      PlantSeed(GridAcross,1);
      Move(VK_UP);
      for i=1, (GridAcross - 1) do
              PlantSeed(i,2);
              Move(VK_RIGHT);
      end
      PlantSeed(GridAcross,2);
      Move(VK_UP);
      for i=1, (GridAcross - 1) do
              PlantSeed(i,3);
              Move(VK_LEFT);
      end
      PlantSeed(GridAcross,3); 

end

function PlantSeed(intAcross, intDown)

safeClick(mousePos[0], mousePos[1]);
PinAt((intAcross-1)*WindowAcross,intDown*WindowDown);

end

function Move(MoveDirection)

sleepWithStatus(DelayBeforePlanting, "Moving." .. EndMessage);
srKeyDown(MoveDirection);
sleepWithStatus(DelayMoving, "Moving." .. EndMessage);
srKeyUp(VK_ALL);
sleepWithStatus(DelayAfterPlanting, "Moving." .. EndMessage);

end

function PinAt(incX,incY)

local deviationAcross = 60
local deviationDown = -60

srClickMouse(xyCenter[0]+deviationAcross, xyCenter[1]-deviationDown,0);
sleepWithStatus(50, "Pinning Window." .. EndMessage);
srClickMouse(xyCenter[0]+deviationAcross+5, xyCenter[1]-deviationDown-5,1);
sleepWithStatus(50, "Pinning Window." .. EndMessage);
dragWaitSource(xyCenter[0]+deviationAcross, xyCenter[1]-deviationDown,incX,incY)
sleepWithStatus(50, "Pinning Window." .. EndMessage);

end

function dragWaitSource(x0, y0, x1, y1)

      srMouseDown(x0, y0, 0);
      sleepWithStatus(50, "Dragging Window." .. EndMessage);
      srSetMousePos(x1, y1);
      sleepWithStatus(50, "Dragging Window." .. EndMessage);
      srMouseUp(x1, y1, 0);
      sleepWithStatus(50, "Dragging Window." .. EndMessage);
      srSetMousePos(x0, y0);

end