User:Peter/Scripts

From ATITD7

Jump to: navigation, search

Wood gather script

Notes - Piles 4 saltpeter into the tree after you gather

--
-- 
--

dofile("screen_reader_common.inc");
dofile("ui_utils.inc");

per_tree_delay_time = 5000;
total_delay_time = 80000;
carrot_delay_time = 10*60*1000;

function doit()
	carrot_timer = lsGetTimer();
	askForWindow("Pin 5-10 tree windows, will click them VERTICALLY (left to right if there is a tie - multiple columns are fine).  Additionally, optionally, pin a Bonfire and Consume window for stashing wood and eating grilled carrots (first carrot will be consumed after 10 minutes).");
	-- Find windows
	srReadScreen();
	xyWindowSize = srGetWindowSize();
	local buttons = findAllImages("GatherWood.png");
	if #buttons == 0 then
		error 'Could not find any Gather Wood buttons';
	end
	while 1 do
		for i=1, #buttons do
			-- srReadScreen();
			statusScreen("Grabbing Wood " .. i .. "/" .. #buttons);
			srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]);
			lsSleep(1000);
			srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]);
			lsSleep(1000);
			srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]);
			lsSleep(1000);
			srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]);
			lsSleep(1000);
			srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]);
			lsSleep(1000);
			srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]);
			lsSleep(1000);
		end
		srReadScreen();
		bonfire = srFindImage("Bonfire.png");
		if bonfire then
			statusScreen("Found bonfire...");
			add_wood = srFindImage("AddSomeWood.png");
			if add_wood then
				-- add it
				statusScreen("Adding wood to bonfire");
				srClickMouseNoMove(add_wood[0]+5, add_wood[1]+5);
				lsSleep(500);
				-- click Max
				srClickMouseNoMove(xyWindowSize[0]/2, xyWindowSize[1]/2 + 55);
			else
				statusScreen("No add wood button, refreshing bonfire");
				-- refresh bonfire window
				srClickMouseNoMove(bonfire[0]+5, bonfire[1]+5);
			end
		end
		
		carrots = srFindImage("EatSomeGrilledCarrots.png");
		
		local time_left = 20000;
		local eat_carrots = nil;
		if (time_left > 0) then
			local start_time = lsGetTimer();
			while time_left - (lsGetTimer() - start_time) > 0 do
				time_left2 = time_left - (lsGetTimer() - start_time);
				carrot_note = "";
				if carrots then
					carrot_time_left = carrot_timer + carrot_delay_time - lsGetTimer();
					if carrot_time_left < 0 then
						carrot_time_left = 0;
						eat_carrots = 1;
					end
					carrot_note = "  " .. math.floor(carrot_time_left / 1000) .. "s until eating carrots.";
				else
					carrot_note = "";
				end
				statusScreen("Waiting " .. time_left2 .. "ms before starting next pass..." .. carrot_note);
				lsSleep(100);
				checkBreak();
			end
		end
		if eat_carrots then
			srReadScreen();
			carrots = srFindImage("EatSomeGrilledCarrots.png");
			if carrots then
				srClickMouseNoMove(carrots[0]+5, carrots[1]+5);
				carrot_timer = lsGetTimer();
			end
		end
	end
end

Almbec Fruity Spirits setting

Notes: Set temp to fruity and great Q

  • add high tannin wine and let veggie spirits Ra, Life or Air distil out a bit
  • Add bit of sugar wine let more distil out a little
  • then add DRY beer
  • leave to see if any will distil out, if nothing happens after 5 mins or so, drop the temp to grain, but keep a close eye on it and be ready to switch back to fruity imediately as soon as fruit appears
  • Fruit setting will hold the fruit spirit at the same Q and no gain in the sink so harvest. I tried to get more or improve the Q but messed up and it quickly changes to grey or veggie spirits.
-- alembic.lua v1.0 -- by Tallow
--
-- Automatically maintain the temperature on an alembic at a given point.
--

dofile("common.inc");

--pot = makePoint(255, 239);
flow = makePoint(21, 326+9);
flowSmall = makePoint(31 - flow[0], 233 - flow[1]);
flowLarge = makePoint(31 - flow[0], 317 - flow[1]);
tempMinus = makePoint(86 - flow[0], 308 - flow[1]);
tempPlus = makePoint(86 - flow[0], 260 - flow[1]);

tempBar = 63 - flow[0];
tempBackgroundColor = 0xece0c1

heatSpots = {
  makePoint(tempBar, 230 - flow[1]), -- Fish
  makePoint(tempBar, 242 - flow[1]), -- Mineral
  makePoint(tempBar, 254 - flow[1]), -- Vegetable
  makePoint(tempBar, 263 - flow[1]), -- Fruity
  makePoint(tempBar, 292 - flow[1]), -- Grain
  makePoint(tempBar, 304 - flow[1]), -- Worm
  makePoint(tempBar, 318 - flow[1]), -- Wood
  makePoint(tempBar, 329 - flow[1]), -- Rock
  makePoint(0, 0) -- Off
};

heatNames = {
    "Fish",
    "Mineral",
    "Vegetable",
    "Fruity",
    "Grain",
    "Worm",
    "Wood",
    "Rock",
    "Off"
};

qualityNames = {
  "Great",
  "Good",
  "Moderate",
  "Low",
};

NO_HEAT = 9;

-- notes
-- flow = 21 - 255 + 255, 326 - 230 + 239
-- flow == 21, 326
-- pot == 255, 230

-- fish: 230
-- mineral: 242
-- vegetable: 254
-- fruit: 263
-- grain: 292
-- worm: 304
-- wood: 318
-- rock: 329
-- flow-small: 31, 233
-- flow-large: 31, 317
-- temp-minus: 86, 308
-- temp-plus: 86, 260
-- temp-bar: 63

-- temp-color: 0xf57364

heat_delay = 1000;

isRising = {};
isSmall = {};

function doit()
  askForWindow("Alembic Control v1.0 by Tallow\n \nAutomatically maintain the temperature on an alembic at a given point.\n \nPress shift over ATITD window to continue.");
  alembicControl();
end

function alembicControl()
  local done = false;
  local heat = NO_HEAT;
  local quality = 2;
  local deadline = lsGetTimer();
  while not done do
    lsPrint(5, 110, 0, 1.0, 1.0, 0xd0d0d0ff, "Heat:");
    heat = lsDropdown("AlembicHeat", 90, 110, 0, 180, heat, heatNames);
    lsPrint(5, 140, 0, 1.0, 1.0, 0xd0d0d0ff, "Quality:");
    quality = lsDropdown("AlembicQuality", 90, 140, 0, 180, quality,
			 qualityNames);
    statusScreen("Alembic Control Center");

    if lsGetTimer() > deadline then
      srReadScreen();
      local anchors = findAllImages("alembic-flow.png");
      for i=1,#anchors do
	isRising[i] = maintainHeat(anchors[i], heat, isRising[i]);
	isSmall[i] = maintainQuality(anchors[i], quality, heat, isSmall[i]);
      end
      deadline = lsGetTimer() + heat_delay;
    end
  end
end

function maintainHeat(anchor, index, lastRise)
  local rise = heatShouldRise(anchor, index);
  if rise and lastRise then
    safeClick(anchor[0] + tempPlus[0],
	      anchor[1] + tempPlus[1]);
  elseif not rise and lastRise then
    safeClick(anchor[0] + tempMinus[0],
	      anchor[1] + tempMinus[1]);
  end
  return rise;
end

function heatShouldRise(anchor, index)
  local result = false;
  if index ~= NO_HEAT then
    result = pixelMatch(anchor, heatSpots[index], tempBackgroundColor, 20);
  end
  return result;
end

function maintainQuality(anchor, quality, heat, lastSmall)
  local top = makePoint(heatSpots[heat][0],
			heatSpots[heat][1] - quality - 2);
  local bottom = makePoint(heatSpots[heat][0],
			   heatSpots[heat][1] + quality + 1);
  local small = (heat == NO_HEAT
		 or not pixelMatch(anchor, top, tempBackgroundColor, 20)
		 or pixelMatch(anchor, bottom, tempBackgroundColor, 20));
  if small and not lastSmall then
    safeClick(anchor[0] + flowSmall[0],
	      anchor[1] + flowSmall[1]);
  elseif not small and lastSmall then
    safeClick(anchor[0] + flowLarge[0],
	      anchor[1] + flowLarge[1]);
  end
  return small;
end


Personal tools