Skip to content

Commit

Permalink
Merge pull request #27 from Cegaiel/Apr_15_2012
Browse files Browse the repository at this point in the history
Apr 15 2012
  • Loading branch information
Vaevictusnet committed Apr 15, 2012
2 parents c2e0657 + 310bcd5 commit 7acb0b6
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 140 deletions.
4 changes: 2 additions & 2 deletions VeggieTales/luaScripts/thistle_custom.lua
Expand Up @@ -13,7 +13,7 @@ loadfile("luaScripts/ui_utils.inc")();

per_click_delay = 0;

local expected_gardens = 19;
local expected_gardens = 12;
local last_sun = 99;

instructions = {
Expand Down Expand Up @@ -203,7 +203,7 @@ end

function doit()
num_loops = promptNumber("How many passes ?", 1);
askForWindow("Pin any number of thistle gardnes, edit thistle_custom with recipe.");
askForWindow("Pin any number of thistle gardens, edit thistle_custom with recipe.");

if not ( #instructions == 41*5) then
error 'Invalid instruction length';
Expand Down
2 changes: 1 addition & 1 deletion VeggieTales/luaScripts/thistle_new.lua
Expand Up @@ -273,7 +273,7 @@ end

function doit()
num_loops = promptNumber("How many passes ?", 1);
askForWindow("Pin any number of thistle gardnes, edit thistle_custom with recipe.");
askForWindow("Pin any number of thistle gardens, edit thistle_new with recipe.");

if not ( #instructions == 41*5) then
error 'Invalid instruction length';
Expand Down
64 changes: 32 additions & 32 deletions VeggieTales/luaScripts/window_arranger.lua
Expand Up @@ -8,7 +8,7 @@ loadfile("luaScripts/ui_utils.inc")();
local window_w = 410;
local window_h = 312;
local dropdown_cur_value = 1;
local choice = "Brick Racks";
local windowname = "Brick Racks";

local scale = 0.6;
local z = 0.0; -- Only matters if there is overlapping elements on screen
Expand All @@ -30,65 +30,62 @@ dropdown_values = {"Brick Rack", "Carpentry Shop", "Kettle", "Kiln", "Paper Pres
function GetLayout()


-- Add new sections here

if (dropdown_cur_value == 1) then
choice = "Brick Racks";
if (dropdown_cur_value == 1) then
windowname = "Brick Rack";
-- brick racks
dx = 170;
dy = 115;
little_dx = 0;
num_high = 7;


elseif (dropdown_cur_value == 2) then
choice = "Carpentry Shop";
elseif (dropdown_cur_value == 2) then
windowname = "Carpentry Shop";
-- carpentry shop
dx = 280;
dy = 205;
little_dx = 0;
num_high = 4;



elseif (dropdown_cur_value == 3) then
choice = "Kettles";
elseif (dropdown_cur_value == 3) then
windowname = "Kettles";
-- kettles
dx = 165;
dy = 275;
little_dx = 0;
num_high = 3;


elseif (dropdown_cur_value == 4) then
choice = "Kilns";
elseif (dropdown_cur_value == 4) then
windowname = "Kilns";
-- Kilns
dx = 285;
dy = 180;
little_dx = 0;
num_high = 4;


elseif (dropdown_cur_value == 5) then
choice = "Paper Press";
elseif (dropdown_cur_value == 5) then
windowname = "Paper Press";
-- paper presses
dx = 388;
dy = 100;
little_dx = 0;
num_high = 8;

elseif (dropdown_cur_value == 6) then
choice = "Pottery Wheel";

elseif (dropdown_cur_value == 6) then
windowname = "Pottery Wheel";
-- pottery wheels
dx = 190;
dy = 150;
little_dx = 0;
num_high = 7;



elseif (dropdown_cur_value == 7) then
choice = "Rock Saw";
elseif (dropdown_cur_value == 7) then
windowname = "Rock Saw";
-- rock saws
dx = 137;
dy = 125;
Expand All @@ -97,34 +94,37 @@ choice = "Rock Saw";
window_w = 340;


elseif (dropdown_cur_value == 8) then
choice = "Thistle Custom";
elseif (dropdown_cur_value == 8) then
windowname = "Thistle";
-- thistle_custom
dx = 413; -- when wrapping
dx = 420; -- when wrapping
dy = 190;
little_dx = 0; -- for every window
num_high = 5;
num_high = 4;


elseif (dropdown_cur_value == 9) then
choice = "Thistle New";
elseif (dropdown_cur_value == 9) then
windowname = "Thistle";
-- thistle_new
dx = 413; -- when wrapping
dy = 24;
little_dx = 8; -- for every window
num_high = 33;


-- Add more layouts below, between this line and the 'else' statement below.
-- The below 'else' statement is a copy of the original script, not sure what it's for, but added it just in case.

-- The subsequent/future layout statement would be 'elseif (dropdown_cur_value == 10) then'
-- The 2nd next subsequent/future layout statement would be 'elseif (dropdown_cur_value == 11) then', etc...
-- Add new sections here





else





else

-- setting permissions
dx = 413+55; -- when wrapping
Expand All @@ -136,7 +136,7 @@ else



end
end

end

Expand Down Expand Up @@ -233,7 +233,7 @@ end
GetLayout();


askForWindow("Pin any number of " .. choice .. " windows. Will be arranged according to settings in window_arranger.lua. Press Shift to continue.");
askForWindow("Pin any number of \'" .. windowname .. "\' windows. They will be arranged according to settings in window_arranger.lua. Press Shift to continue.");



Expand Down
136 changes: 31 additions & 105 deletions VeggieTales/luaScripts/window_unpin.lua
Expand Up @@ -11,24 +11,39 @@ 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 = 10; -- Time is in ms
per_click_delay = 0; -- Time is in ms


searchImage1 = "ThisIs.png" -- Method 1
searchImage2 = "Unpin.png" -- Method 2

repeatMethod1 = 1;
repeatMethod2 = 1;


function doit()


-- Pause, say something to user, wait for Shift key to continue. Give opportunity to put ATITD in focus, if needed.
askForWindow("Press Shift key to right click all windows.");
askForWindow("This will right click all windows, attempting to close any pinned windows. Press Shift key continue.");

--Keep looking for and closing windows with Image1 until no more found, then move to Method 2.

while repeatMethod1 == 1 do
closeMethod1();
end


--Keep looking for and closing windows with Image2 until no more found, then done.

while repeatMethod2 == 1 do
closeMethod2();
end

end



--------------------------------- METHOD 1 ---------------------------------

function closeMethod1()


-- Search Method 1:
Expand All @@ -41,136 +56,47 @@ function doit()
local buttons = findAllImages(searchImage1);

if #buttons == 0 then

statusScreen("Search method 1/2 failed!");
lsSleep(1000);

repeatMethod1 = 0
else
statusScreen("Search method 1/2:\nFound " .. #buttons .. " windows");
lsSleep(1000);
statusScreen("Search method 1/2:\nClicking " .. #buttons .. " windows");
lsSleep(1000);


for i=#buttons, 1, -1 do

srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]+3, right_click);
lsSleep(per_click_delay);

end

-- If any windows were found, with Method 1, then inform user when done clicking.
if #buttons > 0 then
statusScreen("Search method 1/2:\nDone clicking " .. #buttons .. " windows");
lsSleep(1000);
end


end

checkBreak();
end


-- Done Method 1




------------------------------------------------------------------------------



-- Do another check (Method 2) for Unpin.png, if Thisis.png was not found, then it could mean 2 reasons:

-- Reason 1: Some buildings, like Warehouse, which shows 'This Small Warehouse' would fool Method 1.
-- Why don't I use this.png instead to avoid that?
-- Because many buildings may show 'This' twice. ie Kiln: "'This' is a True Kiln, 'This' True Kiln will survive 2 firings".
-- or "'This' is a greenhouse, 'This' greenhouse is growing Grass"
-- While the script would still work correctly with this.png, I use thisIs.png so that it doesn't make one window show as 2 in the status message.
-- In other words, if I had one greenhouse pinned, it would say it found 2 windows, because it found the word 'This' twice.

-- Reason 2: Maybe a flax bed window went to a seed. If you refresh a flax bed window, after going to seed, it would turn blank, only leaving the unpin.png method to find and close it.


-- Why don't I use Method 2 only, instead of both Method 1 and 2? Wouldn't the unpin.png (Method 2) cover all scenarios?

-- Yes it would, except for this scenario: the "thistle new" layout (from windows_arranger.lua)...
-- With this layout, Method 2 (Unpin.png) will only close one window out at a time :( I don't know why, but it does. I even tried changing the image, no luck :(
-- So this is the reason to the methods...


------------------------------------------------------------------------------


-- Why did I use #buttons2 below instead of using #buttons again?
-- Yes, I could have used #buttons again below, instead of #buttons2.
-- The only reason that I used #buttons2 instead of #buttons is to add the totals of #buttons + #buttons2 at bottom. I wanted 2 different values.
-- If I had used #buttons again, then the value (above) would have been overwritten on Method 2 (below).
-- If not for the 'Total clicked:' thing, I would not have needed to use #buttons2, just FYI.


function closeMethod2()

--------------------------------- METHOD 2 ---------------------------------

-- Search Method 2:


-- Find pinned windows with searchImage2
srReadScreen();

-- Count how many windows that were found and assign the value to #buttons2
local buttons2 = findAllImages(searchImage2);
-- Count how many windows that were found and assign the value to #buttons
local buttons = findAllImages(searchImage2);

if #buttons2 == 0 then

statusScreen("Search method 2/2 failed!");
lsSleep(1000);

if #buttons == 0 then
repeatMethod2 = 0
else
statusScreen("Search method 2/2:\nFound " .. #buttons2 .. " windows");
lsSleep(1000);
statusScreen("Search method 2/2:\nClicking " .. #buttons2 .. " windows");
lsSleep(1000);


for i=#buttons2, 1, -1 do

srClickMouseNoMove(buttons2[i][0]+5, buttons2[i][1]+3, right_click);
for i=#buttons, 1, -1 do
srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]+3, right_click);
lsSleep(per_click_delay);

end


-- If any windows were found, with Method 2, then inform user when done clicking.
if #buttons2 > 0 then
statusScreen("Search method 2/2:\nDone clicking " .. #buttons2 .. " windows");
lsSleep(1000);
end


end


-- Done Method 2



------------------------------------------------------------------------------


-- Just an unneeded/optional message to user, before we finish the doit() function
-- If any windows found, with either Method 1 (#buttons) or Method 2 (#buttons2), then show the total windows clicked. Else say Sorry, try again.

if #buttons + #buttons2 > 0 then
--statusScreen("Total clicked: " .. #buttons + #buttons2 .. " windows");
statusScreen("Method 1 clicked: " .. #buttons .. "\nMethod 2 clicked: " .. #buttons2 .. "\n---------------------------\nTotal clicked: " .. #buttons + #buttons2);
else
statusScreen("Sorry, didn't find any windows. Maybe try again with ATITD in focus!");
end
lsSleep(5000);


------------------------------------------------------------------------------



checkBreak();
end

0 comments on commit 7acb0b6

Please sign in to comment.