Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Apr 16 2012 #28

Merged
merged 6 commits into from

2 participants

@Cegaiel
Collaborator

Updates:
windows_unpin.lua - Bug Fix
windows_arranger.lua - Typo fix.
thistle_custom.lua - Refills water after running thistle garden(s).
thistle_new.lua - Refills water after running thistle garden(s).

Add:
thistle_new_mix_beta.lua - Allows mixing of both upgraded and non upgraded gardens - TEMP FIX
IconWaterJugsSmall.png - Supports the refill water routine all all thistle garden files.

Cegaiel added some commits
@Cegaiel Cegaiel Increased per_click_delay from 0 to 100, plus added a 200 delay in be…
…tween Search Method 1 and 2. This will help prevent extra clicks near other critical locations, such as the 'pyramid icon'. Example: closing windows near the pyramid icon when using the thistle_new layout. Windows that are close to the pyramid icon could cause it to click the pyramid icon many times and in between each click lag will cause a severe reaction, game locking up.
fb036bf
@Cegaiel Cegaiel Minor edit. askforWindow (Press Shift to continue menu) now shows 'Th…
…istle Gardens' instead of 'Thistle' when choosing a 'Thistle Custom' or 'Thistle New' layout option.
9ec2c42
@Cegaiel Cegaiel Now attempts to refill water jugs after every thistle run, with an up…
…dated RefillWater() method. Refill icon no longer is hardcoded, now it searches for the water icon to click. If not found, no error presented. Searches for the new iconWaterJugSmall.png file.
c5e1468
@Cegaiel Cegaiel Now attempts to refill water jugs after every thistle run, with an up…
…dated RefillWater() method. Refill icon no longer is hardcoded, now it searches for the water icon to click. If not found, no error presented. Searches for the new iconWaterJugSmall.png file.
fb728b7
@Cegaiel Cegaiel A temporary fix to the issue of mixing upgraded and non upgraded this…
…tle gardens, while using thistle_new.lua. You can use all upgraded or all non upgraded thistle gardens with thistle_new.lua, but if you attempt to mix any combinations, the macro breaks. The Thistle_new_mix_beta_lua file is the same as thistle_new.lua but will allow you to mix gardens, but beware, you can only run a maximum of 20 gardens with this method, as it is slower. Thanks to Tallow for providing this temporary fix.
cb2e1f4
@Cegaiel Cegaiel Renamed file. 4de16ed
@Vaevictusnet Vaevictusnet merged commit b9c201b into Vaevictusnet:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 16, 2012
  1. @Cegaiel

    Increased per_click_delay from 0 to 100, plus added a 200 delay in be…

    Cegaiel authored
    …tween Search Method 1 and 2. This will help prevent extra clicks near other critical locations, such as the 'pyramid icon'. Example: closing windows near the pyramid icon when using the thistle_new layout. Windows that are close to the pyramid icon could cause it to click the pyramid icon many times and in between each click lag will cause a severe reaction, game locking up.
  2. @Cegaiel

    Minor edit. askforWindow (Press Shift to continue menu) now shows 'Th…

    Cegaiel authored
    …istle Gardens' instead of 'Thistle' when choosing a 'Thistle Custom' or 'Thistle New' layout option.
  3. @Cegaiel

    Now attempts to refill water jugs after every thistle run, with an up…

    Cegaiel authored
    …dated RefillWater() method. Refill icon no longer is hardcoded, now it searches for the water icon to click. If not found, no error presented. Searches for the new iconWaterJugSmall.png file.
  4. @Cegaiel

    Now attempts to refill water jugs after every thistle run, with an up…

    Cegaiel authored
    …dated RefillWater() method. Refill icon no longer is hardcoded, now it searches for the water icon to click. If not found, no error presented. Searches for the new iconWaterJugSmall.png file.
  5. @Cegaiel

    A temporary fix to the issue of mixing upgraded and non upgraded this…

    Cegaiel authored
    …tle gardens, while using thistle_new.lua. You can use all upgraded or all non upgraded thistle gardens with thistle_new.lua, but if you attempt to mix any combinations, the macro breaks. The Thistle_new_mix_beta_lua file is the same as thistle_new.lua but will allow you to mix gardens, but beware, you can only run a maximum of 20 gardens with this method, as it is slower. Thanks to Tallow for providing this temporary fix.
  6. @Cegaiel

    Renamed file.

    Cegaiel authored
This page is out of date. Refresh to see the latest.
View
BIN  VeggieTales/images/iconWaterJugSmall.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
369 VeggieTales/luaScripts/Thistle_new_mix_beta.lua
@@ -0,0 +1,369 @@
+--
+-- 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 = 0;
+
+instructions = {
+0,0,1,1,0,
+0,0,0,0,0,
+0,0,0,0,0,
+0,0,0,1,0,
+0,0,0,0,0,
+0,0,0,1,0,
+0,0,0,0,0,
+0,0,0,1,0,
+0,0,1,0,0,
+0,0,0,1,0,
+0,0,2,0,0,
+0,0,0,0,0,
+0,0,0,0,0,
+0,0,1,1,0,
+0,0,0,0,0,
+0,0,1,0,0,
+0,0,0,1,0,
+0,0,1,0,0,
+0,0,0,1,0,
+0,0,0,0,0,
+0,0,1,1,0,
+0,0,1,1,0,
+0,0,0,0,0,
+0,0,0,0,0,
+0,0,0,1,0,
+0,0,0,1,0,
+0,0,0,0,0,
+0,0,0,2,0,
+0,0,0,2,0,
+0,0,0,0,0,
+0,0,0,0,0,
+0,0,0,0,0,
+0,0,2,0,0,
+0,0,3,1,0,
+0,0,0,0,0,
+0,0,0,0,0,
+0,0,1,1,0,
+0,0,0,0,0,
+0,0,0,1,0,
+0,0,0,1,0,
+0,0,0,0,0,
+};
+
+
+local window_locs = {};
+
+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!
+ local dpos = {};
+ 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
+ srReadScreen();
+ for dindex=1, #image_names do
+ local 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
+ 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
+ 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;
+local last_mon = {};
+for x=1, mon_w do
+ last_mon[x] = {};
+ for y=1, mon_h do
+ last_mon[x][y] = 0;
+ end
+end
+
+function waitForMonChange(message)
+ srReadScreen();
+
+ if not first_nit then
+ first_nit = srFindImage("ThistleNit.png");
+ end
+ if not first_nit then
+ error "Could not find first Nit";
+ end
+ mon_x = first_nit[0] - 25;
+ mon_y = first_nit[1] + 13;
+
+ local different = nil;
+ local skip_next = nil;
+ local first_loop = 1;
+ while not different do
+ srReadScreen();
+ for x=1, mon_w do
+ for y=1, mon_h do
+ newvalue = srReadPixelFromBuffer(mon_x + x, mon_y + y);
+ if not (newvalue == last_mon[x][y]) then
+ different = 1;
+ end
+ last_mon[x][y] = newvalue;
+ end
+ end
+ if not different then
+ first_loop = nil;
+ end
+
+ if different then
+ -- Make sure the screen was done refreshing and update again
+ lsSleep(60);
+ srReadScreen();
+ for x=1, mon_w do
+ for y=1, mon_h do
+ last_mon[x][y] = srReadPixelFromBuffer(mon_x + x, mon_y + y);
+ end
+ end
+ end
+
+ if (different and skip_next) then
+ skip_next = nil;
+ different = nil;
+ end
+
+ lsPrintWrapped(10, 5, 0, lsScreenX - 20, 1, 1, 0xFFFFFFff, message);
+ lsPrintWrapped(10, 60, 0, lsScreenX - 20, 1, 1, 0xFFFFFFff, "Waiting for change...");
+ if lsButtonText(lsScreenX - 110, lsScreenY - 30, z, 100, 0xFFFFFFff, "End script") then
+ error "Clicked End Script button";
+ end
+
+ if lsButtonText(40, lsScreenY - 60, z, 200, 0xFFFFFFff, "Force tick") then
+ different = 1;
+ end
+
+ if lsButtonText(40, lsScreenY - 90, z, 200, 0xFFFFFFff, "Skip tick") then
+ skip_next = 1;
+ end
+
+ if lsButtonText(40, lsScreenY - 120, z, 200, 0xFFFFFFff, "Finish up") then
+ finish_up = 1;
+ end
+
+ -- display mon pixels
+ for x=1, mon_w do
+ for y=1, mon_h do
+ local size = 2;
+ lsDisplaySystemSprite(1, 10+x*size, 90+y*size, 0, size, size, last_mon[x][y]);
+ end
+ end
+ lsDoFrame();
+ lsSleep(100);
+ end
+ statusScreen("Changed, waiting a moment for other beds to catch up...");
+ if not first_loop then -- Don't wait, we might be behind already!
+ lsSleep(1500); -- Wait a moment after image changes before doing the next tick
+ end
+end
+
+function test()
+
+ local loop=0;
+ while 1 do
+ waitForMonChange("tick " .. loop);
+
+ statusScreen('Changed!');
+ lsSleep(1000);
+ loop = loop + 1;
+ end
+
+ error 'done';
+end
+
+function refillWater()
+ statusScreen("Refilling water...");
+ lsSleep(200);
+ srReadScreen();
+ FindWater = srFindImage("iconWaterJugSmall.png", 1);
+
+ if FindWater then
+ srClickMouseNoMove(FindWater[0]+3,FindWater[1]-5);
+ lsSleep(1500);
+
+
+ srReadScreen();
+ FindMaxButton = srFindImage("Maxbutton.png", 1);
+
+
+ if FindMaxButton then
+ srClickMouseNoMove(FindMaxButton[0]+3,FindMaxButton[1]+3);
+ end
+
+ end
+end
+
+function doit()
+ num_loops = promptNumber("How many passes ?", 1);
+ askForWindow("This is a TEMPORARY fix for running a mixture of Upgraded and Non Upgraded Thistle Gardens. This version moves slow and you can only run 20 gardens max. Pin any number of thistle gardens, edit thistle_new_mix_beta with recipe. Press Shift to continue.");
+
+ if not ( #instructions == 41*5) then
+ error 'Invalid instruction length';
+ end
+
+ srReadScreen();
+ window_locs = findAllImages("ThisIs.png");
+ if not (#window_locs == expected_gardens) then
+ error ("Did not find expected number of thistle gardens (found " .. #window_locs .. " expected " .. expected_gardens .. ")");
+ end
+
+-- wl2 = {};
+-- wl2[1] = window_locs[31];
+-- wl2[2] = window_locs[32];
+-- window_locs = wl2;
+-- if not (#window_locs == 2) then
+-- error 'fail';
+-- end
+
+
+ -- test();
+
+ for loops=1, num_loops do
+
+ -- clickAll("ThisIs.png", 1);
+ -- lsSleep(100);
+
+ srReadScreen();
+
+ -- clickAllComplex({"Harvest.png"}, 1);
+ -- error 'done';
+
+
+ -- clickAllComplex({"ThistleAbort.png"}, 1);
+ -- error 'done';
+
+
+ -- statusScreen("(" .. loops .. "/" .. num_loops .. ") Doing initial 2s wait...");
+ -- lsSleep(2000);
+ --waitForMonChange("Getting initial image...");
+ for i=0, 39 do
+ local to_click = {};
+ if (i == 0) then
+ to_click[1] = "ThistlePlantACrop.png";
+ end
+ for j=0, 3 do
+ for k=1, instructions[i*5 + j + 1] do
+ to_click[#to_click+1] = button_names[j+1];
+ end
+ end
+ if not (instructions[i*5 + 5] == last_sun) then
+ last_sun = instructions[i*5 + 5];
+ to_click[#to_click+1] = button_names[5];
+ end
+ if #to_click > 0 then
+ clickAllComplex(to_click, ("(" .. loops .. "/" .. num_loops .. ") " .. i .. ":"));
+ end
+ waitForMonChange("(" .. loops .. "/" .. num_loops .. ") Tick " .. i .. " done.");
+ if (i == 0) then -- first one immediately finds a change
+ waitForMonChange("(" .. loops .. "/" .. num_loops .. ") Tick " .. i .. " done.");
+ end
+ if finish_up then
+ num_loops = loops;
+ end
+ end
+
+ lsSleep(3000);
+ clickAllComplex({"Harvest.png"});
+ lsSleep(500);
+
+ refillWater();
+
+ if finish_up then
+ break;
+ end
+ end
+ lsPlaySound("Complete.wav");
+end
View
24 VeggieTales/luaScripts/thistle_custom.lua
@@ -195,10 +195,24 @@ end
function refillWater()
statusScreen("Refilling water...");
- srClickMouseNoMove(359, 13);
- lsSleep(100);
- srClickMouseNoMove(srGetWindowSize()[0]/2 + 10, srGetWindowSize()[1]/2 + 20);
- lsSleep(4000);
+ lsSleep(200);
+ srReadScreen();
+ FindWater = srFindImage("iconWaterJugSmall.png", 1);
+
+ if FindWater then
+ srClickMouseNoMove(FindWater[0]+3,FindWater[1]-5);
+ lsSleep(1500);
+
+
+ srReadScreen();
+ FindMaxButton = srFindImage("Maxbutton.png", 1);
+
+
+ if FindMaxButton then
+ srClickMouseNoMove(FindMaxButton[0]+3,FindMaxButton[1]+3);
+ end
+
+ end
end
function doit()
@@ -261,7 +275,7 @@ function doit()
clickAll("Harvest.png", nil);
lsSleep(500);
- refillWater(); -- Hack - won't work unless things are arranged precisely, and does no checking
+ refillWater();
if finish_up then
break;
View
24 VeggieTales/luaScripts/thistle_new.lua
@@ -265,10 +265,24 @@ end
function refillWater()
statusScreen("Refilling water...");
- srClickMouseNoMove(359, 13);
- lsSleep(100);
- srClickMouseNoMove(srGetWindowSize()[0]/2 + 10, srGetWindowSize()[1]/2 + 20);
- lsSleep(4000);
+ lsSleep(200);
+ srReadScreen();
+ FindWater = srFindImage("iconWaterJugSmall.png", 1);
+
+ if FindWater then
+ srClickMouseNoMove(FindWater[0]+3,FindWater[1]-5);
+ lsSleep(1500);
+
+
+ srReadScreen();
+ FindMaxButton = srFindImage("Maxbutton.png", 1);
+
+
+ if FindMaxButton then
+ srClickMouseNoMove(FindMaxButton[0]+3,FindMaxButton[1]+3);
+ end
+
+ end
end
function doit()
@@ -344,7 +358,7 @@ function doit()
clickAllComplex({"Harvest.png"});
lsSleep(500);
- refillWater(); -- Hack - won't work unless things are arranged precisely, and does no checking
+ refillWater();
if finish_up then
break;
View
4 VeggieTales/luaScripts/window_arranger.lua
@@ -95,7 +95,7 @@ function GetLayout()
elseif (dropdown_cur_value == 8) then
- windowname = "Thistle";
+ windowname = "Thistle Garden";
-- thistle_custom
dx = 420; -- when wrapping
dy = 190;
@@ -104,7 +104,7 @@ function GetLayout()
elseif (dropdown_cur_value == 9) then
- windowname = "Thistle";
+ windowname = "Thistle Garden";
-- thistle_new
dx = 413; -- when wrapping
dy = 24;
View
18 VeggieTales/luaScripts/window_unpin.lua
@@ -1,9 +1,10 @@
-- Macro by Cegaiel
--- This will right click all windows, in an attempt to unpin and close them all.
--- It searches for windows with BOTH 'ThisIs.png' and 'Unpin.png' to ensure nothing is missed.
--- This script does nothing more than right click on windows. If they are pinned, a right click will close them all (as intended).
--- If any or all of your windows exist, but not pinned , then this macro would pin them (not intended), keep that in mind!
-
+-- This will right click all windows found (both searchImage1 or searchImage2), in an attempt to unpin and close all pinned windows.
+-- It right clicks (closes) every open window that currently shows on screen, in one pass.. If it finds any windows to click then:
+ --Repeat and search for more windows and close all found in another pass again, repeat.
+ -- The purpose of repeating is in case you had any windows were hidden behind other windows from the previous right clicks/close windows.
+ -- Repeat above until no more windows are found. Then do Search Method 2 (another .png) for expired windows (ie. flax bed that turned to seed and window turned blank)
+-- Repeat same pattern for Method 2, until no more windows are found, then exit.
loadfile("luaScripts/screen_reader_common.inc")();
@@ -11,7 +12,7 @@ loadfile("luaScripts/ui_utils.inc")();
right_click = true; -- Set this boolean to 'true' to do right clicks. If this was blank or false, then it would do left clicks.
-per_click_delay = 0; -- Time is in ms
+per_click_delay = 150; -- Time is in ms
searchImage1 = "ThisIs.png" -- Method 1
@@ -32,6 +33,8 @@ function doit()
end
+lsSleep(200);
+
--Keep looking for and closing windows with Image2 until no more found, then done.
while repeatMethod2 == 1 do
@@ -59,7 +62,8 @@ function closeMethod1()
repeatMethod1 = 0
else
-
+--srClickMouseNoMove
+--srSetMousePos
for i=#buttons, 1, -1 do
srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]+3, right_click);
lsSleep(per_click_delay);
Something went wrong with that request. Please try again.