<commit_before>--
-- To run:
--  Copy a recipe from the output of the Thistle Mode
--  Update expected_gardens equal to the number you have opened and pinned
--    Gardens must all have their buttons visible, can overlap as long as the
--    row with "asc" is visible regardlesss of which window was clicked last
--  Update "last sun" to be what it is now (0 if night,
--    99 if daylight and open lid, 33 if daylight and closed lid)
--

loadfile("luaScripts/screen_reader_common.inc")();
loadfile("luaScripts/ui_utils.inc")();

per_click_delay = 0;

local expected_gardens = 33;
local last_sun = 99;

instructions = {
0,0,0,0,99,
0,0,0,0,99,
0,0,0,0,33,
0,0,0,1,99,
0,0,0,0,99,
0,0,0,0,33,
0,0,0,1,99,
0,0,1,0,33,
0,0,1,4,33,
0,0,2,0,33,
0,0,0,1,33,
0,0,0,0,33,
0,0,0,1,99,
0,0,0,0,99,
0,0,3,0,33,
0,0,0,0,99,
0,0,0,0,99,
0,0,1,0,99,
0,0,0,0,33,
0,0,2,0,33,
0,0,1,1,33,
0,0,0,1,33,
0,0,1,0,99,
0,0,0,0,33,
0,0,0,1,33,
0,0,0,3,33,
0,0,0,0,33,
0,0,0,1,99,
0,0,0,1,99,
0,0,2,0,99,
0,0,1,0,99,
0,0,1,0,99,
0,0,1,2,99,
0,0,0,0,99,
0,0,0,0,99,
0,0,0,0,33,
0,0,0,0,99,
0,0,0,0,33,
0,0,0,0,99,
0,0,0,0,99,
0,0,0,0,99,
};


local window_locs = {};
local button_pos = {};

local dpos = {};
local pos = {};



function setWaitSpot(x0, y0)
	setWaitSpot_x = x0;
	setWaitSpot_y = y0;
	setWaitSpot_px = srReadPixel(x0, y0);
end

function waitForChange()
	local c=0;
	while srReadPixel(setWaitSpot_x, setWaitSpot_y) == setWaitSpot_px do
		lsSleep(1);
		c = c+1;
		if (lsShiftHeld() and lsControlHeld()) then
			error 'broke out of loop from Shift+Ctrl';
		end
	end
	-- lsPrintln('Waited ' .. c .. 'ms for pixel to change.');
end



function clickAll(image_name, up)
	-- Find buttons and click them!
	srReadScreen();
	xyWindowSize = srGetWindowSize();
	local buttons = findAllImages(image_name);
	
	if #buttons == 0 then
		statusScreen("Could not find specified buttons...");
		lsSleep(1500);

	else
		statusScreen("Clicking " .. #buttons .. "button(s)...");
		if up then
			for i=#buttons, 1, -1  do
				srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]+3);
				lsSleep(per_click_delay);
			end
		else
			for i=1, #buttons  do
				srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]+3);
				lsSleep(per_click_delay);
			end
		end
		statusScreen("Done clicking (" .. #buttons .. " clicks).");

		lsSleep(100);
	end
end



function clickAllComplex(image_names, message)
	if not message then
		message = "";
	end
	-- Find buttons and click them!
	statusScreen(message .. " Clicking " .. #window_locs .. " button(s)...");
	local first = 1;
	for i=#window_locs, 1, -1 do
		if not first then
			-- focus
			setWaitSpot(window_locs[i+1][0], window_locs[i+1][1]);
			srClickMouseNoMove(window_locs[i][0], window_locs[i][1]);
			waitForChange();
		end

		--lsSleep(85);


		for dindex=1, #image_names do


		  if not button_pos[i] then
		    button_pos[i] = {};

		  end
		  pos = button_pos[i][image_names[dindex]];


		  if not pos then
		    srReadScreen();
		    pos = srFindImageInRange(image_names[dindex], window_locs[i][0], window_locs[i][1],
						   410, 312);
		    if not pos then
		      error ('Failed to find ' .. image_names[dindex]);
		    end
		    button_pos[i][image_names[dindex]] = pos;
		  end
		  dpos[dindex] = pos;
		end
		-- click all buttons
		for j=1, #image_names do
			srClickMouseNoMove(dpos[j][0] + 5, dpos[j][1] + 5);
		end
		first = nil;
	end

	lsSleep(100);
	statusScreen(message .. " Refocusing...");
	-- refocus
	for i=2, #window_locs do
		setWaitSpot(window_locs[i][0], window_locs[i][1]);
		srClickMouseNoMove(window_locs[i][0], window_locs[i][1] + 310);
		waitForChange();

	end
	--waitForChange();
lsSleep(100);
end



button_names = {"ThistleNit.png", "ThistlePot.png", "ThistleH2O.png", "ThistleOxy.png", "ThistleSun.png"};

local z = 2;

-- Initialize last_mon
local mon_w = 10;
local mon_h = 152;<commit_msg>Down shuffle (refocus) is very fast now (almost instantly). Should keep up with 25+ gardens now.<commit_after>--
-- To run:
--  Copy a recipe from the output of the Thistle Mode
--  Update expected_gardens equal to the number you have opened and pinned
--    Gardens must all have their buttons visible, can overlap as long as the
--    row with "asc" is visible regardlesss of which window was clicked last
--  Update "last sun" to be what it is now (0 if night,
--    99 if daylight and open lid, 33 if daylight and closed lid)
--

loadfile("luaScripts/screen_reader_common.inc")();
loadfile("luaScripts/ui_utils.inc")();

per_click_delay = 0;

local expected_gardens = 20;
local last_sun = 99;

instructions = {
0,0,0,0,99,
0,0,0,0,99,
0,0,0,0,33,
0,0,0,1,99,
0,0,0,0,99,
0,0,0,0,33,
0,0,0,1,99,
0,0,1,0,33,
0,0,1,4,33,
0,0,2,0,33,
0,0,0,1,33,
0,0,0,0,33,
0,0,0,1,99,
0,0,0,0,99,
0,0,3,0,33,
0,0,0,0,99,
0,0,0,0,99,
0,0,1,0,99,
0,0,0,0,33,
0,0,2,0,33,
0,0,1,1,33,
0,0,0,1,33,
0,0,1,0,99,
0,0,0,0,33,
0,0,0,1,33,
0,0,0,3,33,
0,0,0,0,33,
0,0,0,1,99,
0,0,0,1,99,
0,0,2,0,99,
0,0,1,0,99,
0,0,1,0,99,
0,0,1,2,99,
0,0,0,0,99,
0,0,0,0,99,
0,0,0,0,33,
0,0,0,0,99,
0,0,0,0,33,
0,0,0,0,99,
0,0,0,0,99,
0,0,0,0,99,
};


local window_locs = {};
local button_pos = {};

local dpos = {};
local pos = {};



function setWaitSpot(x0, y0)
	setWaitSpot_x = x0;
	setWaitSpot_y = y0;
	setWaitSpot_px = srReadPixel(x0, y0);
end

function waitForChange()
	local c=0;
	while srReadPixel(setWaitSpot_x, setWaitSpot_y) == setWaitSpot_px do
		lsSleep(1);
		c = c+1;
		if (lsShiftHeld() and lsControlHeld()) then
			error 'broke out of loop from Shift+Ctrl';
		end
	end
	-- lsPrintln('Waited ' .. c .. 'ms for pixel to change.');
end



function clickAll(image_name, up)
	-- Find buttons and click them!
	srReadScreen();
	xyWindowSize = srGetWindowSize();
	local buttons = findAllImages(image_name);
	
	if #buttons == 0 then
		statusScreen("Could not find specified buttons...");
		lsSleep(1500);

	else
		statusScreen("Clicking " .. #buttons .. "button(s)...");
		if up then
			for i=#buttons, 1, -1  do
				srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]+3);
				lsSleep(per_click_delay);
			end
		else
			for i=1, #buttons  do
				srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]+3);
				lsSleep(per_click_delay);
			end
		end
		statusScreen("Done clicking (" .. #buttons .. " clicks).");

		lsSleep(100);
	end
end



function clickAllComplex(image_names, message)
	if not message then
		message = "";
	end
	-- Find buttons and click them!
	statusScreen(message .. " Clicking " .. #window_locs .. " button(s)...");
	local first = 1;
	for i=#window_locs, 1, -1 do
		if not first then
			-- focus
			setWaitSpot(window_locs[i+1][0], window_locs[i+1][1]);
			srClickMouseNoMove(window_locs[i][0], window_locs[i][1]);
			waitForChange();
		end

		--lsSleep(85);


		for dindex=1, #image_names do


		  if not button_pos[i] then
		    button_pos[i] = {};

		  end
		  pos = button_pos[i][image_names[dindex]];


		  if not pos then
		    srReadScreen();
		    pos = srFindImageInRange(image_names[dindex], window_locs[i][0], window_locs[i][1],
						   410, 312);
		    if not pos then
		      error ('Failed to find ' .. image_names[dindex]);
		    end
		    button_pos[i][image_names[dindex]] = pos;
		  end
		  dpos[dindex] = pos;
		end
		-- click all buttons
		for j=1, #image_names do
			srClickMouseNoMove(dpos[j][0] + 5, dpos[j][1] + 5);
		end
		first = nil;
	end

	lsSleep(100);
	statusScreen(message .. " Refocusing...");
	-- refocus
	for i=2, #window_locs do
		setWaitSpot(window_locs[i][0], window_locs[i][1]);
		srClickMouseNoMove(window_locs[i][0], window_locs[i][1] + 310);
		--waitForChange();
		--lsSleep(75);
	end
	lsSleep(300);
	waitForChange();
	lsSleep(100);
end



button_names = {"ThistleNit.png", "ThistlePot.png", "ThistleH2O.png", "ThistleOxy.png", "ThistleSun.png"};

local z = 2;

-- Initialize last_mon
local mon_w = 10;
local mon_h = 152;
{'fraction_non_alphanumeric': 0.17637977614820533, 'fraction_numerical': 0.08580985462498392, 'mean_word_length': 3.980140935297886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4927470', 'n_tokens_mistral': 3819, 'n_tokens_neox': 3356, 'n_words': 740}