<commit_before>assert(loadfile("luaScripts/Flax_stable.lua"))();

askText = singleLine([[
  onions_stable v1.0 (by <NAME> Cegaiel) --
  Plant onions and harvest them. --
  Make sure the plant onions window and barrel/aqueduct is pinned and
  on the RIGHT side of the screen. Select the skills tab. Your
  VeggieTales window should also be on the RIGHT side of the
  screen. You must be in F8F8 cam zoomed in.  You may need to F12 at
  low resolutions or hide your chat window (if it starts planting and
  fails to move downward, it probably clicked on your chat
  window). Will plant grid NE of current location.  'Plant all crops
  where you stand' must be ON.  'Right click pins/unpins a menu' must
  be ON.
]]);


plantType = ONIONS;

grid_w = 4;
grid_h = 4;

-- Plant more densely than flax
walk_px_y = 140;
walk_px_x = 170;

-- Override flax default, allow a few ms more in case lag messed the
-- walk. Less forgiving, by lag, on tight grids from onions vs flax.
walk_time = 500;

-- This is clicking each window very slow. So it doesn't do a double
-- or triple watering animation on same plant (caused by clicking too
-- fast) Too many double or triple watering animations will steal some
-- of the time. Just as long as it clicks all windows before you can
-- walk from first to last plant is fine.
click_water_delay = 1400;

refresh_time = 200;
click_delay = 150;

seedImage = "Onion Seeds";
waterImage = "WaterThese.png";
harvestImage = "HarvestThese.png";
leafImage = "OnionLeaf.png";

yLeafRadius = 43;
xLeafRadius = 38;

function harvestAll(loop_count)
  local timing = 24000;
  local harvest_timing = 15000;

  if grid_w == 1 then
    -- 1x1 grid
    timing = 19000;
    harvest_timing = 0;
    
  elseif grid_w == 2 then
    -- 2x2 grid
    timing = 15000;
    harvest_timing = 1000;

  elseif grid_w == 3 then
    -- 3x3 grid
    timing = 9000;
    harvest_timing = 6000;

  else
    -- 4x4 grid 
    timing = 0;
    harvest_timing = 10000;
  end
  local globalStr = "[" .. loop_count .. "/" .. num_loops .. "] Passes" .. "\n";

  for pass=1,4 do
    local passStr = "[" .. 5-pass .. "] Growths until Harvest\n"
    srReadScreen();
    local waters = findAllImages(waterImage);
    for i=#waters,1,-1 do
      safeClick(waters[i][0] + 5, waters[i][1] + 5);
      sleepWithStatus(click_water_delay, globalStr .. passStr ..
		      "[" .. i .. "] Watering plants...");
    end
    sleepWithStatus(timing + click_water_delay*(grid_w*grid_w - #waters),
		    globalStr .. passStr .. "Waiting for next growth");
  end
  local anchors = findAllImages(waterImage);
  local current = #anchors;
  local range = getWindowBorders(anchors[current][0], anchors[current][1]);
  while current > 0 do
    local updates = findAllImages("ThisIs.png", range);
    clickAllPoints(updates);
    srReadScreen();
    local harvests = findAllImages(harvestImage, range);
    for i=1,#harvests do
      safeClick(harvests[i][0], harvests[i][1]);
      lsSleep(click_delay);
      safeClick(harvests[i][0], harvests[i][1] - 15, 1);
      statusScreen("[" .. i .. "] Harvesting plants...");
      lsSleep(click_delay);
      current = current - 1;
      if current > 0 then
	range = getWindowBorders(anchors[current][0], anchors[current][1]);
      end
    end
    lsSleep(10);
    checkBreak();
  end
  sleepWithStatus(harvest_timing,
		  globalStr .. "Waiting for harvest to finish.");
end

function clickPlant(plantButton)
  local tol = 1000;
  srReadScreen();<commit_msg>Update onion seed window at the end.<commit_after>assert(loadfile("luaScripts/Flax_stable.lua"))();

askText = singleLine([[
  onions_stable v1.0 (by Tallow and Cegaiel) --
  Plant onions and harvest them. --
  Make sure the plant onions window and barrel/aqueduct is pinned and
  on the RIGHT side of the screen. Select the skills tab. Your
  VeggieTales window should also be on the RIGHT side of the
  screen. You must be in F8F8 cam zoomed in.  You may need to F12 at
  low resolutions or hide your chat window (if it starts planting and
  fails to move downward, it probably clicked on your chat
  window). Will plant grid NE of current location.  'Plant all crops
  where you stand' must be ON.  'Right click pins/unpins a menu' must
  be ON.
]]);


plantType = ONIONS;

grid_w = 4;
grid_h = 4;

-- Plant more densely than flax
walk_px_y = 140;
walk_px_x = 170;

-- Override flax default, allow a few ms more in case lag messed the
-- walk. Less forgiving, by lag, on tight grids from onions vs flax.
walk_time = 500;

-- This is clicking each window very slow. So it doesn't do a double
-- or triple watering animation on same plant (caused by clicking too
-- fast) Too many double or triple watering animations will steal some
-- of the time. Just as long as it clicks all windows before you can
-- walk from first to last plant is fine.
click_water_delay = 1400;

refresh_time = 200;
click_delay = 150;

seedImage = "Onion Seeds";
waterImage = "WaterThese.png";
harvestImage = "HarvestThese.png";
leafImage = "OnionLeaf.png";

yLeafRadius = 43;
xLeafRadius = 38;

function harvestAll(loop_count)
  local timing = 24000;
  local harvest_timing = 15000;

  if grid_w == 1 then
    -- 1x1 grid
    timing = 19000;
    harvest_timing = 0;
    
  elseif grid_w == 2 then
    -- 2x2 grid
    timing = 15000;
    harvest_timing = 1000;

  elseif grid_w == 3 then
    -- 3x3 grid
    timing = 9000;
    harvest_timing = 6000;

  else
    -- 4x4 grid 
    timing = 0;
    harvest_timing = 10000;
  end
  local globalStr = "[" .. loop_count .. "/" .. num_loops .. "] Passes" .. "\n";

  for pass=1,4 do
    local passStr = "[" .. 5-pass .. "] Growths until Harvest\n"
    srReadScreen();
    local waters = findAllImages(waterImage);
    for i=#waters,1,-1 do
      safeClick(waters[i][0] + 5, waters[i][1] + 5);
      sleepWithStatus(click_water_delay, globalStr .. passStr ..
		      "[" .. i .. "] Watering plants...");
    end
    sleepWithStatus(timing + click_water_delay*(grid_w*grid_w - #waters),
		    globalStr .. passStr .. "Waiting for next growth");
  end
  local anchors = findAllImages(waterImage);
  local current = #anchors;
  local range = getWindowBorders(anchors[current][0], anchors[current][1]);
  while current > 0 do
    local updates = findAllImages("ThisIs.png", range);
    clickAllPoints(updates);
    srReadScreen();
    local harvests = findAllImages(harvestImage, range);
    for i=1,#harvests do
      safeClick(harvests[i][0], harvests[i][1]);
      lsSleep(click_delay);
      safeClick(harvests[i][0], harvests[i][1] - 15, 1);
      statusScreen("[" .. i .. "] Harvesting plants...");
      lsSleep(click_delay);
      current = current - 1;
      if current > 0 then
	range = getWindowBorders(anchors[current][0], anchors[current][1]);
      end
    end
    lsSleep(10);
    checkBreak();
  end
  sleepWithStatus(harvest_timing,
		  globalStr .. "Waiting for harvest to finish.");
  getPlantWindowPos();
end

function clickPlant(plantButton)
  local tol = 1000;
  srReadScreen();
{'fraction_non_alphanumeric': 0.11092003439380911, 'fraction_numerical': 0.03181427343078246, 'mean_word_length': 3.154166666666667, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, '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': '5923353', 'n_tokens_mistral': 2518, 'n_tokens_neox': 2278, 'n_words': 775}