The Wiki for Tale 6 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

Difference between revisions of "User:Selune"

From ATITD6
Jump to navigationJump to search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
Selune's updated VT Macros. If you know how to upload changes to TaleScripts, PLEASE contact me! Thanks!
+
Selune's Macros have been updated to the TaleScripts repository. Please leave any ideas for improvements or new macros here.
  
 
{{Collapse top|title=Paint Reaction Template}}
 
{{Collapse top|title=Paint Reaction Template}}
Line 25: Line 25:
 
{{Collapse bottom}}
 
{{Collapse bottom}}
  
{{Collapse top|title=VT Paint Watch with Reset}}
+
{{Collapse top|title=Fishing Macro for Testing}}
 
<pre>
 
<pre>
--
+
-- Pin up your Lures menu 'Self Click, Skills, Fishing, Use Lure' (no other pinned up windows can exist)
--  
+
-- Should have (Chat-Related): 'Chat and Inventory can be minimized' AND 'Minimized chat-channels are still visible'.
--
+
-- You must have Main Chat tab showing at all times and window is long/wide enough so no lines don't wrap.
  
--Cabbage | 129, 63, 145  | 8      | Y | bulk    | 10
+
-- Yes, this macro reads your MAIN chat screen, so make sure you read the above statement for it to work correctly.
--Carrot | 225, 113, 33  | 10    | Y | bulk    | 10
+
-- Each line of text must not scroll/wrap to the next line. If it does, then drag your chat window wider so it doesn't wrap.
--Clay | 128, 96, 32    | 4      | Y | bulk    | 20
+
-- You want to make your chat very wide. Note: It is possible to see a LONG message like "Though you lost your lure, you did catch a 15 deben Orange Spongefish"
--DeadTongue | 112, 64, 64    | 500    | N | normal  | 4
+
-- Another long message is "You didn't catch anything. You also lost your lure. Try different lures and locations"
--ToadSkin | 48, 96, 48    | 500    | N | normal  | 4
+
-- At 1280x1024 your chat screen should reach at least to the mid point of your screen to avoid having a chat line wrap to next line, for a long message, like above.
--EarthLight | 128, 240, 224  | 10000  | N | normal  | 4
+
-- Higher resolutions may not have to reach quite to the mid point.
--RedSand | 144, 16, 24    | 10    | Y | bulk    | 20
 
--Lead | 80, 80, 96    | 50    | Y | normal  | 6
 
--Silver | 16, 16, 32    | 50    | N | normal  | 6
 
--Iron | 96, 48, 32    | 30    | Y | normal  | 8
 
--Copper | 64, 192, 192  | 30    | Y | normal  | 8
 
  
--Sulfur      | catalyst      | 10    | Y | normal  | 1
 
--Potash      | catalyst      | 50    | Y | normal  | 1
 
--Lime        | catalyst      | 20    | Y | normal  | 1
 
--Saltpeter  | catalyst      | 10    | Y | normal  | 1
 
  
-- 317, 55, 71
+
-- ********** This macro writes to a log file (Fishlog.txt) for most actions, so you can review later! ******
--                 cj  ca  cl  dt  ts  el  rs  le  si  ir  co  su  po li sp
+
-- ********** This also macro writes to a log file (Fishstats.txt) showing stats of your last fishing session, so you can review later! ******
paint_colourR = { 129, 225, 129, 112, 48,  128, 145, 81,  16,  97,  64  };
 
paint_colourG = { 64,  113, 97,  64,  96,  240, 16,  81,  16,  48, 194  };
 
paint_colourB = { 145, 33,  33,  64,  48,  224, 24,  97,  32,  33, 194  };
 
catalyst1 = 12;
 
  
loadfile("luaScripts/screen_reader_common.inc")();
 
loadfile("luaScripts/ui_utils.inc")();
 
loadfile("luascripts/common.inc")();
 
  
button_names = {
+
--You can delete any of the log files if you wish. It will automatically create new ones if they dont exist.
"CabbageJ","Carrot","Clay","DeadTongue","ToadSkin","EarthLight","RedSand",
+
--The fishlog.txt file gets appended everytime you fish, so the file can grow quite long over time.
"Lead","SilverP","Iron","Copper","C:Sulfur","C:potash","C:Lime","C:Saltpeter"};
+
--The fishstats.txt file gets overwritten everytime your gui program window updates, so it doesn't 'grow' over time.
  
per_paint_delay_time = 1000;
 
per_read_delay_time = 600;
 
per_click_delay = 10;
 
  
 +
-- "Main chat tab is not showing" and other errors can usually be overcome by adjusting the main chat window size and restarting, assuming main chat is showing.
 +
-- And also verify the lines aren't wrapping.
  
function doit()
 
  
local paint_sum = {0,0,0};
+
-- The very first thing this macro does is to Self Click, Special, What Time is it? option. This will then display the time in main chat window.
local paint_count = 0;
+
-- The macro then parses time displayed, in main chat tab, so it can use it while the macro runs (Log files and on screen display).
local bar_colour = {0,0,0};
+
-- Thats what the mysterious Self Click is doing, its not a bug, it is suppose to do that and thats why, to fetch the time.
local expected_colour = {0,0,0};
 
local diff_colour = {0,0,0};
 
local new_px = 0xffffffFF;
 
local px_R = nil;
 
local px_G = nil;
 
local px_B = nil;
 
local px_A = nil;
 
local m_x = 0;
 
local m_y = 0;
 
local update_now = 1;
 
local y=0;
 
local button_push = 0;
 
  
lsSetCaptureWindow();
 
  
askForWindow("Open the paint window. Take any paint away so to start with 'Black'.");
+
-- Note: These are currently refered to as Common Fish in the below 'SkipCommon' type of fishes (True or False), in the 'Custom Variables' section.
  
 +
--Abdju
 +
--Chromis
 +
--Catfish
 +
--Carp
 +
--Perch
 +
--Phagrus
 +
--Tilapia
  
srReadScreen();
 
xyWindowSize = srGetWindowSize();
 
local colour_panel = findAllImages("paint-black.png");
 
if (#colour_panel == 0) then
 
m_x, m_y = srMousePos();
 
else
 
m_x = colour_panel[1][0];
 
m_y = colour_panel[1][1];
 
end
 
  
local paint_buttons = findAllImages("paint-button.png");
 
if (#paint_buttons == 0) then
 
error "No buttons found";
 
end
 
  
 +
--CUSTOM VARIABLES -- EDIT HERE To Change Fishing Casts, Skips, Updates.
  
while 1 do
+
TotalCasts=3; --Total Casts per lure, if a fish caught. If no fish then it skips.
lsSetCamera(0,0,lsScreenX*1.5,lsScreenY*1.5);
+
SkipCommon = false; --Skips to next lure if fish caught is a common (Choose True or False).
-- Where to start putting buttons/text on the screen.
+
LureChangesToUpdateTimer = 7; --Total lures used before time is updated. Zero updates every new lure.
y=0;
+
IgnoreUnknown = false; --Continues the script if fish is not recognized
 
if lsButtonText(lsScreenX - 30, lsScreenY - 80, 0, 100, 0xFFFFFFff, "Reset") then
 
for i= 1, 10 do
 
srClickMouseNoMove(paint_buttons[7][0]+2,paint_buttons[7][1]+2, right_click);
 
lsSleep(per_click_delay);
 
end
 
srReadScreen();
 
lsSleep(100);
 
clickAllText("Take the Paint");
 
lsSleep(100);
 
paint_sum = {0,0,0};
 
paint_count = 0;
 
bar_colour = {0,0,0};
 
expected_colour = {0,0,0};
 
diff_colour = {0,0,0};
 
new_px = 0xffffffFF;
 
px_R = nil;
 
px_G = nil;
 
px_B = nil;
 
px_A = nil;
 
m_x = 0;
 
m_y = 0;
 
update_now = 1;
 
end
 
  
-- Create each button and set the button push.
+
--AlmostCaughtAttempts = 0; --Adds additional attempts to the current lure if Unusual, Strange fish are seen;
for i=1, #button_names do
+
-- Note: AlmostCaughtAttempts above was already commented out upon arriving to Talescripts.
if lsButtonText(10, y, 0, 250, 0xFFFFFFff, button_names[i]) then
+
-- It is also commented out during the script, so uncommenting above will NOT activate the feature.
image_name = button_names[i];
 
update_now = 1;
 
button_push = i;
 
end
 
y = y + 26;
 
end
 
srReadScreen();
 
  
  
-- read the bar pixels
 
new_px = srReadPixel(m_x, m_y);
 
px_R = (math.floor(new_px/256/256/256) % 256);
 
px_G = (math.floor(new_px/256/256) % 256);
 
px_B = (math.floor(new_px/256) % 256);
 
px_A = (new_px % 256);
 
  
if not(update_now==0) then
+
-- Additional reporting in the log file
--{
+
-- Choose True or False.
if not (button_push==0) then
+
-- Note 'LogStrangeUnusual' and 'LogOdd' (below) overrides LogFails setting. ie if LogStrange true, then it would still log even if LogFails = False
--{
+
--If LogFails = false and LogStrangeUnusual or LogOdd = true, then failed catches those would still be included in the log file.  
-- click the appropriate button to add paint.
 
srClickMouseNoMove(paint_buttons[button_push][0]+2,paint_buttons[button_push][1]+2, right_click);
 
lsSleep(per_click_delay);
 
 
if(button_push < catalyst1) then
 
-- add the paint estimate
 
paint_sum[1] = paint_sum[1] + paint_colourR[button_push];
 
paint_sum[2] = paint_sum[2] + paint_colourG[button_push];
 
paint_sum[3] = paint_sum[3] + paint_colourB[button_push];
 
paint_count = paint_count + 1.0;
 
end
 
--}
 
end
 
  
-- count up all the pixels.
 
lsSleep(per_paint_delay_time);
 
srReadScreen();
 
  
bar_colour[1] = #findAllImages("paint-redbarC.png");
+
LogFails = true;  -- Do you want to add Failed Catches to log file? 'Failed to catch anything' or 'No fish bit'. Note the log will still add an entry if you lost lure.
lsSleep(per_read_delay_time/3);
+
LogStrangeUnusual = true; -- Do you want to add Strange and Unusual fish to the log file? Note the log will still add an entry if you lost lure.
bar_colour[2] = #findAllImages("paint-greenbarC.png");
+
LogOdd = true; -- Do you want to add Odd fish to the log file? Note the log will still add an entry if you lost lure.
lsSleep(per_read_delay_time/3);
 
bar_colour[3] = #findAllImages("paint-bluebarC.png");
 
lsSleep(per_read_delay_time/3);
 
update_now = 0;
 
  
-- tweak/hack because we miss the first pixel
 
for i=1, 3 do
 
if(bar_colour[i]>0)then
 
bar_colour[i]=bar_colour[i]+1;
 
bar_colour[i]=bar_colour[i]*256.0/259;
 
end
 
end
 
  
 +
-- END CUSTOM VARIABLES
  
 
-- New colour has been added, mix in the pot, and see if there's a difference from the expected value.
 
if not (button_push==0) then
 
--{
 
for i=1, 3 do
 
expected_colour[i] = paint_sum[i] / paint_count;
 
diff_colour[i] = math.floor(0.5+bar_colour[i]) - math.floor(0.5+expected_colour[i]);
 
end
 
  
button_push = 0;
 
--}
 
end
 
--}
 
end
 
  
-- Display all the goodies
+
loadfile("luaScripts/screen_reader_common.inc")();
lsPrintWrapped(0, y, 1, lsScreenX, 1, 1, 0xFFFFFFff,
+
loadfile("luaScripts/ui_utils.inc")();
" Pixel  RGBA: " .. px_R .. "," .. px_G .. "," .. px_B .. "," .. px_A);
+
loadfile("luaScripts/Fishing_Func.inc")();
y = y + 26;
 
lsPrintWrapped(0, y, 1, lsScreenX, 1, 1, 0xFFFFFFff,
 
" Bar read RGB: " .. math.floor(bar_colour[1]+0.5) .. "," .. math.floor(bar_colour[2]+0.5) .. "," .. math.floor(bar_colour[3]+0.5));
 
y = y + 26;
 
lsPrintWrapped(0, y, 1, lsScreenX, 1, 1, 0xFFFFFFff,
 
" Expected RGB: " .. math.floor(expected_colour[1]+0.5) .. "," .. math.floor(expected_colour[2]+0.5) .. "," .. math.floor(expected_colour[3]+0.5) );
 
y = y + 26;
 
lsPrintWrapped(0, y, 1, lsScreenX, 1, 1, 0xFFFFFFff,
 
" Reactions RGB: " .. math.floor(diff_colour[1]+0.5) .. "," .. math.floor(diff_colour[2]+0.5) .. "," .. math.floor(diff_colour[3]+0.5) );
 
  
  
if lsButtonText(lsScreenX - 30, lsScreenY - 30, 0, 100, 0xFFFFFFff, "Exit") then
 
error "Canceled";
 
end
 
  
lsDoFrame();
+
function SetupLureGroup()
lsSleep(per_read_delay_time);
 
end
 
end
 
</pre>
 
{{Collapse bottom}}
 
  
{{Collapse top|title=Fixed VT Crematory macro}}
+
TLures = {};
<pre>
+
FirstLure="";
-- crematory.lua v1.2 by Tallow
+
LastLure = "";
--
 
-- Runs one or more crematories. Automatically discovers button
 
-- configuration on its own and loads/unloads materials.
 
--
 
  
assert(loadfile("luaScripts/common.inc"))();
 
  
askText = singleLine([[
 
  Crematory v1.2 (by Tallow) --
 
  Automatically runs one or more crematories.
 
]]);
 
  
wmText = "Tap control on Crematories to open and pin.";
+
 +
srReadScreen();
 +
FindPin = srFindImage("UnPin.png");
 +
if FindPin then
 +
  
OPP = 0;
+
--Click the pinup to refresh the lures window
SAME_UP = 1;
 
SAME_DOWN = 2;
 
  
tolerance = 6500;
+
srClickMouseNoMove(FindPin[0]+5,FindPin[1]+30);
tickTime = 1000;
+
lsSleep(500);
maxWait = 1000;
 
longWait = 500;
 
shortWait = 30;
 
  
colOffsets = {
 
  {35-40-3, 204-182},
 
  {71-40-3, 204-182},
 
  {107-40-3, 204-182},
 
  {143-40-3, 204-182},
 
  {179-40-3, 204-182},
 
  {215-40-3, 204-182},
 
  {251-40-3, 204-182}
 
};
 
  
colWidth = 36-35+6;
+
srReadScreen();
colHeight = 323-204;
 
colMiddle = 57;
 
  
buttonOffsets = {
 
  {49-40, 333-182},
 
  {89-40, 333-182},
 
  {129-40, 333-182},
 
  {169-40, 333-182},
 
  {209-40, 333-182}
 
};
 
  
buttonWidth = 78-49;
+
DownPin = srFindImageInRange("Fishing/Menu_DownArrow.png",FindPin[0]-10,FindPin[1],50,500);
buttonHeight = 354-333;
+
if DownPin then
buttonClick = 10;
+
--Just Incase
 +
UpArrow = srFindImageInRange("Fishing/Menu_UpArrow.png",FindPin[0]-10,FindPin[1],50,50);
 +
if UpArrow then
 +
srClickMouseNoMove(UpArrow[0]+5,UpArrow[1]+5);
 +
lsSleep(1000);
 +
srReadScreen();
 +
end
 +
 +
 +
-- srClickMouseNoMove(DownPin[0]+5,DownPin[1]+5);
 +
LastLure=FindLureName(DownPin[0]-150,DownPin[1]-10,150,25);
 +
--error(LastLure);
 +
FirstLure = FindLureName(FindPin[0]-150,FindPin[1]-10,150,25);
 +
-- error(FirstLure);
 +
else
 +
--No Arrows on lure menu?
 +
FirstLure=FindLureName(FindPin[0]-150,FindPin[1]-10,150,25);
 +
LastLure=nil;
 +
end
 +
else
 +
error("Didn\'t find Lures pinned window - Self Click->Skills, Fishing -> Use Lure, PIN THIS WINDOW!");
 +
end
 +
 +
 +
if  LastLure ~= nil then
 +
--We have last lure, and arrows showing
 +
ChangeLureMenu = LastLure;
  
limestoneOffset = 0;
 
leeksOffset = 16;
 
flaxOffset = 32;
 
papyrusOffset = 48;
 
woodOffset = 64;
 
  
load_flax = true;
+
FirstLurLoc = srFindImage("fishing/" .. FirstLure);
load_papyrus = true;
+
LastLurLoc = srFindImage("fishing/" .. LastLure);
load_leeks = true;
+
load_limestone = true;
 
  
currentPass = 1;
 
passCount = 5;
 
  
windows = nil;
+
for i = 1, #Lures,1 do
 +
test = srFindImageInRange(("fishing/" .. Lures[i]),FirstLurLoc[0]-5,FirstLurLoc[1]-5,175,500);
  
-------------------------------------------------------------------------------
+
if test then
-- doit
+
--Add Lure
-------------------------------------------------------------------------------
+
table.insert(TLures,Lures[i]);
 +
if Lures[i] == LastLure then
 +
--End of Menu, Use Down Arrow
 +
arrow=srFindImageInRange("Fishing/menu_downarrow.png",test[0],test[1]-5,175,50);
 +
if arrow then
 +
DownArrowLocs = arrow;
 +
srClickMouseNoMove(arrow[0]+5,arrow[1]+5);
 +
lsSleep(1000);
 +
srReadScreen();
 +
lsSleep(1000);
 +
else
 +
error("no arrow found");
 +
end
 +
end
 +
LastLureMenu = Lures[i];
  
function doit()
+
end
  askForWindow(askText);
+
end
  windowManager("Crematory Setup", wmText);
+
  unpinOnExit(runCrematories);
+
--Reset Lure Menu
end
+
UpArrow = srFindImageInRange("Fishing/Menu_UpArrow.png",FindPin[0]-10,FindPin[1],50,50);
 +
if UpArrow then
 +
srClickMouseNoMove(UpArrow[0]+5,UpArrow[1]+5);
 +
end
 +
 +
else
 +
--No arrows, just get lures
 +
for i = 1, #Lures, 1 do
 +
test = srFindImage("Fishing/" .. Lures[i]);
 +
if test then
 +
table.insert(TLures,Lures[i]);
 +
end
 +
end
 +
end
 +
 +
return TLures;
  
-------------------------------------------------------------------------------
 
-------------------------------------------------------------------------------
 
 
function runCrematories()
 
  promptLoad();
 
  askForFocus();
 
  for i=1,passCount do
 
    currentPass = i;
 
    takeAll();
 
    loadAll();
 
    start();
 
    local is_done = false;
 
    while not is_done do
 
      tick();
 
      is_done = checkDone();
 
    end
 
    sleepWithStatus(longWait*5, updateMessage("Waiting to take"));
 
  end
 
  takeAll();
 
  lsPlaySound("Complete.wav");
 
 
end
 
end
  
-------------------------------------------------------------------------------
+
function FindLureName(x,y,w,h)
-- addWindow
 
-------------------------------------------------------------------------------
 
  
function addWindow(vPos)
+
for i = 1, #Lures, 1 do
  local newWindow = {
+
Lure = srFindImageInRange("Fishing/" .. Lures[i], x,y,w,h);
    origin = {vPos[0], vPos[1]},
+
if Lure then
    ups = {nil, nil, nil, nil, nil},
+
return Lures[i]
    downs = {nil, nil, nil, nil, nil},
+
end
    dirs = {OPP, OPP, OPP, OPP, OPP},
+
end
    double = {false, false, false, false, false, false, false},
 
    probe = 0,
 
    lastPos = nil;
 
    lastDiff = nil;
 
    buttonState = {true, true, true, true, true},
 
    sameCount = 0,
 
    done = false
 
  };
 
  local vFire = srFindImageInRange("crem-fire.png", newWindow.origin[1] - 31,
 
                                  newWindow.origin[2] - 175, 238, 175,
 
                                  tolerance);
 
  if vFire then
 
    newWindow.fire = {vFire[0], vFire[1]};
 
  else
 
    error "No fire button. Do you have Advanced Chemistry?"
 
  end
 
  windows[#windows + 1] = newWindow;
 
 
end
 
end
  
-------------------------------------------------------------------------------
+
function GetLure()
-- resetWindow
 
-------------------------------------------------------------------------------
 
  
function resetWindow(current)
+
srReadScreen();
  local vLime = srFindImageInRange("crem-lime.png", current.origin[1] - 20,
+
                                  current.origin[2] - 20, 100, 100,
+
if CurrentLureIndex == LastLureIndex then
  tolerance);
+
-- Use Down Menu
  if (not vLime) then
+
srClickMouseNoMove(DownArrowLocs[0]-5,DownArrowLocs[1]-5);
    error "Could not find origin again.";
+
srReadScreen();
  end
+
end
  if ((vLime[0] ~= current.origin[1]) or
 
      (vLime[1] ~= current.origin[2])) then
 
    error("Window moved from (" .. current.origin[1] .. ", " ..
 
      current.origin[2] .. ") to (" .. vLime[0] .. ", " .. vLime[1] .. ")");
 
  end
 
  local vFire = srFindImageInRange("crem-fire.png", current.origin[1] - 31,
 
                                  current.origin[2] - 175, 238, 175,
 
                                  tolerance);
 
  if vFire then
 
    current.fire = {vFire[0], vFire[1]};
 
  end
 
  if current.probe < 6 then
 
    current.probe = 0;
 
    current.ups = {nil, nil, nil, nil, nil};
 
    current.downs = {nil, nil, nil, nil, nil};
 
    current.dirs = {OPP, OPP, OPP, OPP, OPP};
 
    current.double = {false, false, false, false, false, false, false};
 
  end
 
  current.lastPos = nil;
 
  current.lastDiff = nil;
 
  current.buttonState = {true, true, true, true, true};
 
  current.sameCount = 0;
 
  current.done = false;
 
end
 
  
-------------------------------------------------------------------------------
+
lure = srFindImage("Fishing/" .. PlayersLures[CurrentLureIndex]);
-- start
+
if not lure then
-------------------------------------------------------------------------------
+
--Failed to find lure
 
+
error("Can\'t find a lure!");
function start()
+
else
  sleepWithStatus(longWait, updateMessage("Waiting to begin"));
+
slure = Lures[PlayersLures[CurrentLureIndex]];
  srReadScreen();
+
slure = string.sub(slure,string.find(slure,"_")+1,string.len(slure) - 4);
  if windows then
+
--statusScreen("Using Lure " .. slure);
    for i=1,#windows do
+
return slure
      resetWindow(windows[i]);
+
end
    end
 
  else
 
    windows = {};
 
    local posList = findAllImages("crem-lime.png");
 
    if #posList == 0 then
 
      error "No crematories found";
 
    end
 
    for i=1,#posList do
 
      addWindow(posList[i]);
 
    end
 
  end
 
  for i=1,#windows do
 
    if windows[i].fire then
 
      safeClick(windows[i].fire[1] + 5, windows[i].fire[2] + 5);
 
      lsSleep(shortWait);
 
    end
 
  end
 
  sleepWithStatus(longWait, updateMessage("Finding my Chi"));
 
  srReadScreen();
 
  for i=1,#windows do
 
    windows[i].lastPos = findPoints(windows[i]);
 
    if not windows[i].lastPos then
 
      windows[i].done = true;
 
    end
 
  end
 
 
end
 
end
  
-------------------------------------------------------------------------------
+
function UseLure()
-- tick
+
-- Uses lure according to CurrentLureIndex, which is used in PlayersLures which contains each lure the player has.
-------------------------------------------------------------------------------
 
  
function tick()
 
  sleepWithStatus(tickTime, updateMessage("Tending Crematory"));
 
  srReadScreen();
 
  for i=1,#windows do
 
    tickWindow(windows[i]);
 
  end
 
  checkBreak();
 
end
 
  
-------------------------------------------------------------------------------
+
if #TLures == 0 then
-- tickWindow
+
error 'Can\'t find any lures on the pinned window. Did you run out of lures?'
-------------------------------------------------------------------------------
+
end
  
function tickWindow(current)
 
  if not current.done then
 
    local points = findPoints(current);
 
    if points then
 
      probeNext(current, points);
 
      if current.probe > 5 then
 
        toggleButtons(current, points, current.buttonState);
 
      end
 
    else
 
      current.done = true;
 
    end
 
  end
 
end
 
  
-------------------------------------------------------------------------------
+
srReadScreen();
-- checkDone
+
lure = srFindImage("Fishing/" .. PlayersLures[CurrentLureIndex]);
-------------------------------------------------------------------------------
 
  
function checkDone()
+
if lure then
  local all_done = true;
+
srClickMouseNoMove(lure[0]+3,lure[1]+3);
  for i=1,#windows do
+
lsSleep(500);
    if not windows[i].done then
+
srReadScreen();
      local done = srFindImageInRange("crem-done.png", windows[i].origin[1] - 3,
+
-- Find Lure Type
                                      windows[i].origin[2] - 15, 40, 40,
+
for i = 1, #Lure_Types, 1 do
                                      tolerance);
+
test = srFindImage("Fishing/" .. Lure_Types[i]);
      if done then
+
if test then
        windows[i].done = true;
+
--Click it!
      else
+
srClickMouseNoMove(test[0]+3,test[1]+3);
        all_done = false;
+
gui_refresh();
      end
+
break;
    end
+
end
  end
+
end
  return all_done;
 
end
 
  
-------------------------------------------------------------------------------
+
end
-- findPoints
+
-------------------------------------------------------------------------------
+
if PlayersLures[CurrentLureIndex] == ChangeLureMenu then
 +
down = srFindImage("Fishing/Menu_DownArrow.png");
 +
srClickMouseNoMove(down[0]+5,down[1]+5);
 +
lsSleep(1000);
 +
elseif PlayersLures[CurrentLureIndex] == LastLureMenu  then
 +
up = srFindImage("Fishing/Menu_UpArrow.png");
 +
srClickMouseNoMove(up[0]+5,up[1]+5);
 +
CurrentLureIndex=1;
 +
lsSleep(1000);
 +
end
 +
  
function findPoints(current)
 
  local result = {};
 
  for i=1,7 do
 
    local offset = {current.origin[1] + colOffsets[i][1],
 
                    current.origin[2] + colOffsets[i][2]};
 
    local point = srFindImageInRange("crem-point.png", offset[1],
 
                                    offset[2] - 5,
 
                                    colWidth, colHeight + 10, tolerance);
 
    if point then
 
      result[i] = point[1] - colOffsets[i][2] - current.origin[2] - colMiddle;
 
    else
 
      result = nil;
 
      break;
 
    end
 
  end
 
  return result;
 
 
end
 
end
  
-------------------------------------------------------------------------------
+
function ChatReadFish()
-- findDiffs
+
--Find the last line of chat
-------------------------------------------------------------------------------
+
lsSleep(100);
 +
srReadScreen();
 +
imgs = findAllImages("fishing/chatlog_reddots.png");
 +
Coords = imgs[#imgs];
 +
 +
-- Look for the ** red dots in main chat to see if they exist.
 +
if #imgs == 0 then
 +
error 'Main chat tab is not showing or the chat window needs to be adjusted!'
 +
end
  
function findDiffs(current, points)
+
  local result = {};
+
--Caught Something..  Find Fish Details
  local all_zero = true;
+
Sfish = "";
  for i=1,7 do
+
    result[i] = points[i] - current.lastPos[i];
+
for i = 1, #CL_Fish do
    if result[i] ~= 0 then
+
ChatFish = srFindImageInRange("Fishing/" .. CL_Fish[i],Coords[0] ,Coords[1],500,25);
      all_zero = false;
+
if ChatFish then
    end
+
Sfish = string.sub(CL_Fish[i],string.find(CL_Fish[i],"Fish_") + 5,string.len(CL_Fish[i]) - 4);
  end
+
GrandTotalCaught = GrandTotalCaught + 1
  if all_zero then
+
break;
    result = nil;
+
end
  end
+
end
  return result;
+
 +
if  string.len(Sfish) < 1 then
 +
-- This fish name and fishname.png file likely needs to be added to Fishing_Func.inc, under the CL_Fish array and the .png added to /Images/Fishing folder
 +
if IgnoreUnknown then
 +
Sfish = "Unknown";
 +
SNum = "1";
 +
else
 +
error("Unknown Fish! PLEASE, Take screenshot (Alt+C) of main chat tab, share with Talescripts team!");
 +
end
 +
else
 +
--Find Size
 +
for i = #CL_Number,1,-1 do
 +
ChatSize =  srFindImageInRange("fishing/" .. CL_Number[i],Coords[0],Coords[1],500,25);
 +
if ChatSize then
 +
SNum = string.sub(CL_Number[i],string.find(CL_Number[i],"_") + 1, string.len(CL_Number[i]) - 4);
 +
break;
 +
end
 +
end
 +
GrandTotaldb = GrandTotaldb + SNum;
 +
end
 +
 +
return(Sfish .. " (" .. SNum .. "db)");
 
end
 
end
  
-------------------------------------------------------------------------------
 
-- probeNext
 
-------------------------------------------------------------------------------
 
  
function probeNext(current, points)
 
  local diffs = findDiffs(current, points);
 
  checkSame(current, diffs);
 
  if diffs and current.probe < 6 then
 
    if current.probe > 0 then
 
      for i=1,7 do
 
        if current.lastDiffs[i] < 0 and diffs[i] > 0 then
 
          if current.ups[current.probe] then
 
            current.downs[current.probe] = i;
 
            current.dirs[current.probe] = SAME_UP;
 
          else
 
            current.ups[current.probe] = i;
 
          end
 
        elseif current.lastDiffs[i] > 0 and diffs[i] < 0 then
 
          if current.downs[current.probe] then
 
            current.ups[current.probe] = i;
 
            current.dirs[current.probe] = SAME_DOWN;
 
          else
 
            current.downs[current.probe] = i;
 
          end
 
        end
 
      end
 
      if current.ups[current.probe] and current.downs[current.probe] then
 
        current.double[current.ups[current.probe]] = true;
 
        current.double[current.downs[current.probe]] = true;
 
      end
 
    end
 
    current.lastPos = points;
 
    current.lastDiffs = diffs;
 
    current.probe = current.probe + 1;
 
    if current.probe <= 5 then
 
      local newProbe = not current.buttonState[current.probe];
 
      local clickX = current.origin[1] + buttonOffsets[current.probe][1] +
 
buttonClick;
 
      local clickY = current.origin[2] + buttonOffsets[current.probe][2] +
 
buttonClick;
 
  
      current.buttonState[current.probe] = newProbe;
+
function findchat(line)
      safeClick(clickX, clickY);
+
--Reads a chat line and returns a basic string for better processing
      lsSleep(shortWait);
+
    end
+
-- Odd fish means your fly fishing skill is not high enough. Raise it with enormous amounts of fishing.
  end
+
-- Strange fish means you need a better rod to catch the rish. You may succeed on future attempts.
end
+
-- Unusual fish means your speed skill was not high enough to catch this type of fish. If it is almost enough, you may catch them on future casts.
  
-------------------------------------------------------------------------------
 
-- checkSame
 
-------------------------------------------------------------------------------
 
  
function checkSame(current, diffs)
+
--Possible fishing messages
  if diffs then
+
-- Caught A (SIZE) Deben (FISH)
    local all_same = true;
+
-- You almost caught a strange fish
    for i=1,#diffs do
+
-- (You almost caught a strange fish. You also lost your lure.)
      if diffs[i] ~= 0 then
+
-- You almost caught an unusual fish
        all_same = false;
+
-- (You almost caught an unusual fish. You also lost your lure.)
      end
+
-- You almost caught an odd fish
    end
+
-- (You almost caught an odd fish. You also lost your lure.)
    if all_same then
+
-- Although you lost your lure  (Caught a fish)
      current.sameCount = current.sameCount + 1;
+
-- Using a (LURE) (TYPE) lure.
    else
+
-- You are carrying more than you can manage.
      current.sameCount = 0;
+
-- You are carrying too much bulk.
    end
+
-- You didn't catch anything.
    if current.sameCount > 10 then
+
-- (You didn't catch anything. You also lost your lure.)
      current.done = true;
+
-- No Fish Bit.
    end
+
-- (No Fish Bit. You also lost your lure.)
  end
 
end
 
  
-------------------------------------------------------------------------------
+
-- toggleButtons
+
--Find the last line of chat
-------------------------------------------------------------------------------
+
lsSleep(100);
 +
srReadScreen();
 +
imgs = findAllImages("Fishing/chatlog_reddots.png");
 +
Coords = imgs[#imgs];
  
function toggleButtons(current, points, buttonState)
+
-- Look for the ** red dots in main chat to see if they exist.
  local balance = getBalance(points, current.double);
+
if #imgs == 0 then
  for i=1,5 do
+
error 'Main chat tab is not showing or the chat window needs to be adjusted!'
    local up = getPointValue(points, current.double, current.ups[i],
+
end
                            balance);
 
    local down = getPointValue(points, current.double, current.downs[i],
 
                              balance);
 
    local goalState = ((up >= 0 and down <= 0) or
 
                      (up >= 0 and down >= 0 and up > down) or
 
                      (up <= 0 and down <= 0 and up > down));
 
    if current.dirs[i] == SAME_UP then
 
      goalState = ((up >= 0 and down >= 0) or
 
                  (up >= 0 and down <= 0 and up >= -down) or
 
                  (up <= 0 and down >= 0 and -up <= down));
 
    elseif current.dirs[i] == SAME_DOWN then
 
      goalState = ((up <= 0 and down <= 0) or
 
                  (up >= 0 and down <= 0 and up <= -down) or
 
                  (up <= 0 and down >= 0 and -up >= down));
 
    end
 
    local goalStateStr = "false";
 
    if goalState then
 
      goalStateStr = "true";
 
    end
 
    local buttonStr = "false";
 
    if buttonState[i] then
 
      buttonStr = "true";
 
    end
 
    if (goalState and not buttonState[i]) or
 
      (not goalState and buttonState[i]) then
 
      safeClick(current.origin[1] + buttonOffsets[i][1] + buttonClick,
 
current.origin[2] + buttonOffsets[i][2] + buttonClick);
 
      lsSleep(shortWait);
 
      buttonState[i] = goalState;
 
    end
 
  end
 
end
 
  
-------------------------------------------------------------------------------
+
-- getBalance
+
if line and line > 0 then
-------------------------------------------------------------------------------
+
Coords = imgs[(#imgs) - line];
 +
if not Coords then
 +
error 'Main chat tab is not showing or the chat window needs to be adjusted!'
 +
end
  
function getBalance(points, double)
+
end
  local above = 0;
+
  local below = 0;
+
--Find What Happened
  for i=1,#points do
 
    if points[i] > 0 and double[i] then
 
      below = below + 1;
 
    elseif points[i] < 0 and double[i] then
 
      above = above + 1;
 
    end
 
  end
 
  
  local result = 0;
+
ChatType = "";
  if above >= 3 then
+
    result = -5;
+
for i = 1, #Chat_Types -1,2 do
  elseif below >= 3 then
+
test = srFindImageInRange("Fishing/" .. Chat_Types[i],Coords[0],Coords[1],500,30);
    result = 5;
+
if test then
  end
+
--Found Chat
  return result;
+
ChatType = Chat_Types[i + 1];
end
+
break;
 +
end
 +
end
 +
 +
 +
--Break down!
 +
if ChatType then
 +
--if ChatType == "lure" then
 +
--elseif ChatType == "nofishlostlure" then
 +
--elseif ChatType == "nofish" then
 +
--elseif ChatType == "strange" then
 +
--elseif ChatType == "unusual" then
 +
return ChatType;
 +
else
 +
error(ChatType);
  
-------------------------------------------------------------------------------
+
end
-- getPointValue
+
-------------------------------------------------------------------------------
+
 
+
function getPointValue(points, double, index, balance)
 
  local result = 0;
 
  if index then
 
    result = points[index];
 
    if not double[index] then
 
      result = result + balance;
 
    end
 
  end
 
  return result;
 
 
end
 
end
  
-------------------------------------------------------------------------------
 
-- takeAll
 
-------------------------------------------------------------------------------
 
  
function takeAll()
 
  srReadScreen();
 
  local updateList = findAllImages("ThisIs.png");
 
  for i=1,#updateList do
 
    safeClick(updateList[i][0], updateList[i][1]);
 
  end
 
  sleepWithStatus(longWait, updateMessage("Update Crematory Windows"));
 
  srReadScreen();
 
  local takeList = findAllImages("crem-take.png");
 
  for i=1,#takeList do
 
    safeClick(takeList[i][0] + 5, takeList[i][1] + 5);
 
    sleepWithStatus(shortWait*2, "Waiting for Everything");
 
    srReadScreen();
 
    local all = waitForImage("Everything.png", maxWait, "Grabbing Everything");
 
    if all then
 
      safeClick(all[0] + 5, all[1] + 5);
 
    end
 
    lsSleep(shortWait*2);
 
  end
 
end
 
  
-------------------------------------------------------------------------------
+
function GetTime()
-- promptLoad
+
--Reads time stamp using special->what time menu
-------------------------------------------------------------------------------
+
winsize = srGetWindowSize();
 +
 +
--Open Menu, Press the Esc key to open the Self Click menu
  
function promptLoad()
+
-- Move mouse to center of screen before Sending the Esc key, to get the Self Click menu. We dont want it self clicking near the edge of screen causing an error.
  scale = 1.0;
+
srSetMousePos(winsize[0]/2,winsize[1]/2);
  local z = 0;
+
lsSleep(100); -- This delay is critical for any srSetMousePos. Without it, the mouse will not have time to actually move!
  local is_done = nil;
 
  while not is_done do
 
    checkBreak("disallow pause");
 
    lsPrint(10, 10, z, scale, scale, 0xFFFFFFff, "Configure");
 
    local y = 60;
 
  
    lsPrint(5, y, z, scale, scale, 0xffffffff, "Passes:");
+
srKeyEvent(string.char(27));  -- Send Esc Key
    is_done, passCount = lsEditBox("passes", 110, y, z, 50, 30, scale, scale,
+
lsSleep(500);
                                  0x000000ff, 5);
+
    if not tonumber(passCount) then
+
--Find Special Menu
      is_done = false;
+
srReadScreen();
      lsPrint(10, y+18, z+10, 0.7, 0.7, 0xFF2020ff, "MUST BE A NUMBER");
+
menu = srFindImage("Fishing/Menu_Special.png");
      passCount = 1;
+
    end
+
if menu then
    y = y + 48;
+
--Click it!
 +
srClickMouseNoMove(menu[0]+3,menu[1]+3);
 +
 +
lsSleep(500);
 +
srReadScreen();
  
    load_flax = lsCheckBox(15, y, z+10, 0xffffffff, "Dried Flax",
+
-- Look for the What Time Is It? option in menu
                          load_flax);
+
menu = srFindImage("Fishing/Menu_WhatTime.png");
    y = y + 32;
+
if menu then
 +
--Click it!
 +
srClickMouseNoMove(menu[0]+3,menu[1]+3);
 +
lsSleep(500);
 +
end
 +
end
  
    load_papyrus = lsCheckBox(15, y, z+10, 0xffffffff, "Dried Papyrus",
 
                              load_papyrus);
 
    y = y + 32;
 
  
    load_leeks = lsCheckBox(15, y, z+10, 0xffffffff, "Leeks",
 
                            load_leeks);
 
    y = y + 32;
 
  
    load_limestone = lsCheckBox(15, y, z+10, 0xffffffff, "Limestone",
+
                                load_limestone);
+
srReadScreen();
    y = y + 32;
+
imgs = findAllImages("Fishing/chatlog_reddots.png");
 +
Coords = imgs[#imgs];
  
    lsPrintWrapped(10, y, z+10, lsScreenX - 20, 0.7, 0.7, 0xd0d0d0ff,
+
-- Look for the ** red dots in main chat to see if they exist.
                  "Make sure each crematory is pinned and empty.");
+
if #imgs == 0 then
 +
error 'Main chat tab is not showing or the chat window needs to be adjusted!'
 +
end
  
    if lsButtonText(10, lsScreenY - 30, z, 100, 0xFFFFFFff, "Begin") then
+
        is_done = 1;
+
for i = #CL_Time, 1, -1 do
    end
+
Stime = srFindImageInRange("Fishing/" .. CL_Time[i],Coords[0],Coords[1],400,25);
    if lsButtonText(lsScreenX - 110, lsScreenY - 30, z, 100, 0xFFFFFFff,
+
if Stime then
                    "End script") then
+
Hour = string.sub(CL_Time[i],string.find(CL_Time[i],"ime_")+4,string.len(CL_Time[i])-4);
      error "Clicked End Script button";
+
    end
+
AM = srFindImageInRange("Fishing/Chatlog_Time_AM.png",Coords[0],Coords[1],400,25);
    lsDoFrame();
+
if AM then
    lsSleep(shortWait);
+
CurrentTime=(Hour .. "AM");
  end
+
return (Hour .. "AM");
end
+
else
 +
PM = srFindImageInRange("Fishing/chatlog_time_PM.png",Coords[0],Coords[1],400,25);
 +
if PM then
 +
CurrentTime=(Hour .. "PM");
 +
return (Hour .. "PM");
 +
end
 +
end
  
-------------------------------------------------------------------------------
+
end
-- loadAll
+
end
-------------------------------------------------------------------------------
 
 
 
function loadAll()
 
  srReadScreen();
 
  local posList = findAllImages("ThisIs.png");
 
  for i=1,#posList do
 
    safeClick(posList[i][0], posList[i][1]);
 
  end
 
  sleepWithStatus(longWait, updateMessage("Update Crematory Windows"));
 
  srReadScreen();
 
  posList = findAllImages("crem-fire.png");
 
  for i=1,#posList do
 
    loadSingle(posList[i], woodOffset, "Wood");
 
    if load_flax then
 
      loadSingle(posList[i], flaxOffset, "Flax");
 
    end
 
    if load_papyrus then
 
      loadSingle(posList[i], papyrusOffset, "Papyrus");
 
    end
 
    if load_leeks then
 
      loadSingle(posList[i], leeksOffset, "Leeks");
 
    end
 
    if load_limestone then
 
      loadSingle(posList[i], limestoneOffset, "Limestone");
 
    end
 
  end
 
 
end
 
end
  
-------------------------------------------------------------------------------
+
function gui_refresh()
-- loadSingle
+
lsDoFrame();
-------------------------------------------------------------------------------
 
  
function loadSingle(pos, offset, type)
 
  sleepWithStatus(200, "Waiting to load");
 
  safeClick(pos[0]+5, pos[1]+5+16);
 
  lsSleep(100);
 
  local limePos = waitForImage("crem-limestone.png", maxWait,
 
      "Loading " .. type .. " Into Crematory");
 
  if limePos then
 
    safeClick(limePos[0] + 5, limePos[1] + 5 + offset);
 
    lsSleep(100);
 
    local maxPos = waitForImage("crem-max.png", maxWait,
 
"Adding Maximum Amount");
 
    if maxPos then
 
      safeClick(maxPos[0]+5, maxPos[1]+5);
 
    end
 
  end
 
  lsSleep(100);
 
  sleepWithStatus(shortWait, "Waiting for load to complete");
 
end
 
  
-------------------------------------------------------------------------------
+
if GrandTotalCaught < 10 then
-- updateMessage
+
last10 = GrandTotalCaught .. "/10";
-------------------------------------------------------------------------------
 
 
 
function updateMessage(message)
 
  local result = "Pass " .. currentPass .. " / " .. passCount .. "\n";
 
  result = result .. message .. "\n\n";
 
  if message == "Tending Crematory" then
 
    for i=1,#windows do
 
      local status = "Buttons: ";
 
      for j=1,5 do
 
if windows[i].dirs[j] == OPP then
 
  status = status .. getDir("+", windows[i].ups[j]) ..
 
    getDir("-", windows[i].downs[j]);
 
elseif windows[i].dirs[j] == SAME_UP then
 
  status = status .. getDir("+", windows[i].ups[j]) ..
 
    getDir("+", windows[i].downs[j]);
 
 
else
 
else
  status = status .. getDir("-", windows[i].ups[j]) ..
+
last10 = 10;
    getDir("-", windows[i].downs[j]);
 
 
end
 
end
if j ~= 5 then
 
  status = status .. ", ";
 
else
 
  status = status .. "\n";
 
end
 
      end
 
      result = result .. "\n" .. status;
 
    end
 
  end
 
  return result;
 
end
 
  
function getDir(sign, number)
 
  local result = "";
 
  if number then
 
    result = sign .. number
 
  end
 
  return result;
 
end
 
</pre>
 
{{Collapse bottom}}
 
  
{{Collapse top|title=Forge.inc to add Treated Metal Sheeting}}
+
--Stats (On Screen Display)
<pre>
+
--CurrentLureIndex  out of  PlayersLures
button_names = {
+
winsize = lsGetWindowSize();
"Knife Blade",
+
"Shovel Blade",
+
"Nails",
+
lsPrintWrapped(10, 0, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Lure Index: " .. CurrentLureIndex .. " out of " .. #PlayersLures .. "       " .. PlayersLures[CurrentLureIndex]);
"Copper Pipe",
+
 
"Lead Pipe",
 
"Bars",
 
"Sheeting",
 
"Straps",
 
"Tools",
 
"Wire"
 
};
 
  
bar_button_names = {
+
lsPrintWrapped(10, 20, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Time: " .. CurrentTime);
"Iron Bar",
 
"Gold Bar",
 
"Silver Bar"
 
};
 
  
sheeting_button_names = {
+
lsPrintWrapped(10, 40, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Last [" .. last10 .. "] Fish Caught:");
"Lead Sheeting",
 
"Gold Sheeting",
 
"Copper Sheeting",
 
"Octecs Alloy Sheeting",
 
"Silver Sheeting",
 
"Steel Sheeting",
 
"Gold Foil",
 
"Metal Blue Sheeting",
 
"Treated Metal Sheeting",
 
"Tin Sheeting",
 
"Moon Steel Sheeting",
 
"Thoths Metal Sheeting"
 
};
 
  
straps_button_names = {
+
--Reset this string before showing last 10 fish below. Else the entries will multiply with entries from previous loops/call to this function
"Water Metal Strap",
+
last10caught = "";
"Iron Strap",
 
"Aluminum Strap",
 
"Copper Strap"
 
};
 
  
tools_button_names = {
+
if #gui_log_fish > 10 then
"Iron Poker",
+
table.remove(gui_log_fish,1);
"Steel Blade",
+
end
"Lead Chisel"
+
for i = 1, #gui_log_fish,1 do
};
+
lsPrintWrapped(10, 50 + (12*i), 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, gui_log_fish[i]);
 +
last10caught = last10caught .. gui_log_fish[i] .. "\n";
 +
end
  
wire_button_names = {
 
"Thoths Metal Wire",
 
"Metal Blue Wire",
 
"Magnesium Wire",
 
"Octecs Alloy Wire",
 
"Silver Wire",
 
"Copper Wire",
 
"Steel Wire",
 
"Gold Wire"
 
};
 
  
 +
lsPrintWrapped(10, winsize[1]-133, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Odd Fish Seen: " .. GrandTotalOdd);
 +
lsPrintWrapped(10, winsize[1]-121, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Unusual Fish Seen: " .. GrandTotalUnusual);
 +
lsPrintWrapped(10, winsize[1]-109, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Strange Fish Seen: " .. GrandTotalStrange);
  
----------------- MAKE PROJECTS 'SUPPORTING' FUNCTIONS -----------------
+
lsPrintWrapped(10, winsize[1]-97, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "-----------------------------");
  
function waitMinutes(minutes)
+
lsPrintWrapped(10, winsize[1]-85, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Lures Clicked: " .. GrandTotalLuresUsed);
-- Teppy Minute is 66 seconds or 66000 ms
+
lsPrintWrapped(10, winsize[1]-73, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Lures Lost: " .. GrandTotalLostLures);
-- Add a 3 second delay (3000 ms) in case of lag
 
  
wait_delay = 3000; -- Extra delay on top of Teppy Time, for lag purposes. Default is 3000
+
lsPrintWrapped(10, winsize[1]-61, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "-----------------------------");
wait = (minutes * 66000) + wait_delay;
 
askForFocus(); -- Pause to allow user to focus back to ATITD (if they checked the Pause for Focus Box), before starting project.
 
end
 
  
 +
lsPrintWrapped(10, winsize[1]-49, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Total Casts: " .. GrandTotalCasts);
 +
lsPrintWrapped(10, winsize[1]-37, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Failed Catches: " .. GrandTotalFailed);
 +
lsPrintWrapped(10, winsize[1]-25, 0, lsScreenX - 20, 0.5, 0.5, 0xFFFFFFff, "Fish Caught: " .. GrandTotalCaught .. " (" .. GrandTotaldb .. "db)");
  
function doneGUI(totalPasses)
 
wait = 5000;  -- Gives a 5 second delay to review the GUI stats, before quitting/returing to Main Menu.
 
clickAllImages("This.png"); -- Refresh the screen. Update forge window so we know how much charcoal is currently in each forge before next project
 
  
sleepWithStatus(wait, "[" .. totalPasses .. "/" .. totalPasses .. "] ALL DONE!\n----------------------------------------------\n[" .. made .. "/" .. batch*project_windows*num_loops .. "] " .. name .. " / Completed");
+
-- Write stats to log file. Everytime the GUI screen is updated, so is the log file.
  
lsPlaySound("Complete.wav");
+
WriteFishStats("Last Session Hour: " .. CurrentTime .. "\n\nOdd Fish Seen: " .. GrandTotalOdd .. "\nUnusual Fish Seen: " .. GrandTotalUnusual .. "\nStrange Fish Seen: " .. GrandTotalStrange .. "\n---------------------\nLures Clicked: " .. GrandTotalLuresUsed .. "\nLures Lost: " .. GrandTotalLostLures .. " \n---------------------\nTotal Casts: " .. GrandTotalCasts .. "\nFailed Catches: " .. GrandTotalFailed .. "\nFish Caught: " .. GrandTotalCaught .. " (" .. GrandTotaldb .. "db)\n---------------------\n\nLast 10 Fish Caught:\n\n".. last10caught);
runForge(); -- Return to/Display Main Menu
 
end
 
  
  
function waitGUI(pass)
 
--If any forge menus shows the Forge_StartFire.png - refreshWindows() function, then display the stalledMessage in the GUI. Suggests its not lit (or out of charcoal)
 
if #stalled > 0 then
 
stalledMessage = "\n[" .. #stalled .. "] Forges STALLED (Needs Lit)"
 
else
 
stalledMessage = "";
 
end
 
  
sleepWithStatus(wait, "[" .. pass .. "/" .. num_loops .. "] Total Passes\n----------------------------------------------\n[" .. batch .. "] " .. name .. " per forge\n[" .. project_windows .. "] Forges working" .. stalledMessage .. "\n----------------------------------------------\n[" .. batch*project_windows .. "] " .. name .. " per pass\n----------------------------------------------\n[" .. made .. "/" .. batch*project_windows*num_loops .. "] " .. name .. " / Completed");
 
  
made = made + (batch*project_windows);
 
 
end
 
end
  
  
function refreshWindows()
 
checkBreak();
 
pinned_windows = clickAllImages("This.png");
 
lsSleep(400);
 
if pinned_windows == 0 then
 
error("No pinned windows found!");
 
else
 
srReadScreen();
 
stalled = findAllImages("Forge/Forge_StartFire.png");
 
if #stalled == pinned_windows/2 then -- The /2 is because each forge has 'This' located in window twice. Can't use ThisIs.png either because idle/working forge has different words (Idle Forge shows 'This' only and Working Forge shows 'This Is'
 
error("No forges are lit!");
 
end
 
end
 
end
 
  
  
----------------- MAKE PROJECT FUNCTIONS -----------------
 
  
function KnifeBlade()
+
function doit()
num_loops = promptNumber("How many passes ?", 1);
+
askForWindow("MAIN chat tab MUST be showing and wide enough so that each lines doesn't wrap. Pin up Lures Menu (Self, Skills, Fishing, Use Lures). No other pinned menus can exist. More detailed instructions are included inside the script as comments at top. There are options you can set in the script such as how many casts per lure, what gets written to the log file and more! History will be recorded in FishLog.txt and stats in FishStats.txt. Most errors can be fixed by slightly adjusting/moving your chat screen! Press Shift to continue.");
batch = 1;
+
 
name = "Knife Blade";
+
--Gui_Main();
waitMinutes(10);
+
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
project_windows = clickAllImages("Forge/Forge_Knife_Blade.png");
 
if project_windows == 0 then
 
sleepWithStatus(1500, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function ShovelBlade()
+
--Variables Used By Program -- Don't Edit Unless you know what you're doing!
num_loops = promptNumber("How many passes ?", 1);
+
CurrentLure = ""; --Don't Edit
batch = 1;
+
gui_log_fish = {}; --Don't Edit, holds log display
name = "Shovel Blade";
+
log_fish = {};
waitMinutes(5);
+
CurrentLureIndex=0; -- 1 = First Lure Player Owns in alphabetical order
for i=1, num_loops do
+
ChangeLureMenu="";
while 1 do
+
LastLureMenu="";
refreshWindows();
+
DownArrowLocs=nil;
project_windows = clickAllImages("Forge/Forge_Shovel_Blade.png");
+
PlayersLures={}; --Don't Edit, Holds Current Player Lures
if project_windows == 0 then
+
CurrentTime=""; --Don't Edit, Holds Time Check Value
sleepWithStatus(1500, "Waiting for Project windows");
+
TotalLuresUsed = 0;
else
+
castcount = 0;
break;
+
--strangecounter = 0;
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function Nails()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 12;
 
name = "Nails";
 
waitMinutes(1);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
project_windows = clickAllImages("Forge/Forge_Nail.png");
 
if project_windows == 0 then
 
sleepWithStatus(1500, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function CopperPipe()
+
--These variables were later added for displaying additional info on the screen.
num_loops = promptNumber("How many passes ?", 1);
+
-- Used for the extra reporting/statistics, on screen.
batch = 1;
+
-- Dont Edit Unless you know what you're doing!
name = "Copper Pipe";
 
waitMinutes(5);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
project_windows = clickAllImages("Forge/Forge_Copper_Pipe.png");
 
if project_windows == 0 then
 
sleepWithStatus(1500, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function LeadPipe()
+
GrandTotalCaught = 0;
num_loops = promptNumber("How many passes ?", 1);
+
GrandTotalCasts = 0;
batch = 1;
+
GrandTotaldb = 0;
name = "Lead Pipe";
+
GrandTotalStrange = 0;
waitMinutes(5);
+
GrandTotalOdd = 0;
for i=1, num_loops do
+
GrandTotalUnusual = 0;
while 1 do
+
GrandTotalLuresUsed = 0;
refreshWindows();
+
GrandTotalLostLures = 0;
project_windows = clickAllImages("Forge/Forge_Lead_Pipe.png");
+
GrandTotalFailed = 0;
if project_windows == 0 then
 
sleepWithStatus(1500, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function IronBar()
+
num_loops = promptNumber("How many passes ?", 1);
+
PlayersLures = SetupLureGroup();
batch = 1;
+
CurrentTime = GetTime();
name = "Iron Bar";
+
lsSleep(1500);
waitMinutes(15);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Bars.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Iron_Bar.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function GoldBar()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 1;
 
name = "Gold Bar";
 
waitMinutes(5);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Bars.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Gold_Bar.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function SilverBar()
+
--Write an entry into log file to show this is a new session
num_loops = promptNumber("How many passes ?", 1);
+
WriteFishLog("[New Session]\n");
batch = 1;
 
name = "Silver Bar";
 
waitMinutes(10);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Bars.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Silver_Bar.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function LeadSheeting()
+
num_loops = promptNumber("How many passes ?", 1);
+
while 1 do
batch = 1;
+
name = "Lead Sheeting";
+
checkBreak();
waitMinutes(10);
+
srReadScreen();
for i=1, num_loops do
+
while 1 do
+
refreshWindows();
+
--cast = srFindImage("Fishing/Button_Fish.png");
clickAllImages("Forge/Forge_Sheeting.png");
+
cast = srFindImage("fishicon.png");
lsSleep(400);
+
if not cast then
project_windows = clickAllImages("Forge/Forge_Lead_Sheeting.png");
+
error("cannot find fishing button");
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
 
end
 
end
doneGUI(num_loops);
+
end
+
if castcount == 0 then
 +
--Update counters
 +
castcount = 1;
 +
CurrentLureIndex = CurrentLureIndex +1;
  
function GoldSheeting()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 4;
 
name = "Gold Sheeting";
 
waitMinutes(10);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Gold_Sheeting.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function CopperSheeting()
+
if CurrentLureIndex > #PlayersLures then
num_loops = promptNumber("How many passes ?", 1);
+
--Refresh the Lure window, and reindex it, in case some were lost.
batch = 1;
+
PlayersLures = SetupLureGroup();
name = "Copper Sheeting";
+
CurrentLureIndex = 1;
waitMinutes(1);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Copper_Sheeting.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
 
end
 
end
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function TreatedSheeting()
 
num_loops = promptNumber("How many passes ?", 1);
 
typeOfMetal = promptText("Enter the metal name:");
 
batch = 1;
 
name = "Treated Metal Sheeting";
 
waitMinutes(2);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllText("Treated");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
lsSleep(400);
 
local numClicked = clickAllText(typeOfMetal);
 
if numClicked == 0 then
 
break;
 
end
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function OctecsAlloySheeting()
+
num_loops = promptNumber("How many passes ?", 1);
+
--Update the time if ready, always update before new lure to keep chat/log proper
batch = 8;
+
if TotalLuresUsed == LureChangesToUpdateTimer then
name = "Octecs Alloy";
+
--Update Time
waitMinutes(20);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Octecs_Alloy_Sheeting.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function SilverSheeting()
+
CurrentTime = GetTime();
num_loops = promptNumber("How many passes ?", 1);
+
TotalLuresUsed = 0;
batch = 1;
 
name = "Silver Sheeting";
 
waitMinutes(2);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Silver_Sheeting.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
 
end
 
end
waitGUI(i);
+
end
+
--Since no casts been made at all, use a lure
doneGUI(num_loops);
+
UseLure();
end
+
lsSleep(2000);
 +
TotalLuresUsed = TotalLuresUsed + 1;
 +
GrandTotalLuresUsed = GrandTotalLuresUsed + 1;
 +
 +
--update log
 +
gui_refresh();
 +
 +
elseif castcount  > TotalCasts then
 +
-- if strangecounter > 0 and strangecounter < AlmostCaughtAttempts then
 +
--we don't reset yet!
 +
-- else
 +
--Reset
 +
castcount=0;
 +
strangecounter = 0;
 +
-- end
 +
else
 +
--Cast
 +
srClickMouseNoMove(cast[0]+3,cast[1]+3);
 +
lsSleep(1000);
 +
checkBreak();
  
function SteelSheeting()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 6;
 
name = "Steel Sheeting";
 
waitMinutes(10);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Steel_Sheeting.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function GoldFoil()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 4;
 
name = "Gold Foil";
 
waitMinutes(1);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Gold_Foil.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function MetalBlueSheeting()
+
while findchat(castcount - 1) == "lure" do
num_loops = promptNumber("How many passes ?", 1);
+
lsSleep(1000);
batch = 1;
+
checkBreak();
name = "Metal Blue Sheeting";
 
waitMinutes(15);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Metal_Blue_Sheeting.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
 
end
 
end
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function TinSheeting()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 1;
 
name = "Tin Sheeting";
 
waitMinutes(5);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Tin_Sheeting.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function MoonSteelSheeting()
+
castcount = castcount + 1;
num_loops = promptNumber("How many passes ?", 1);
+
GrandTotalCasts = GrandTotalCasts + 1;
batch = 1;
 
name = "Moon Steel Sheeting";
 
waitMinutes(5);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Moon_Steel_Sheeting.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function ThothsMetalSheeting()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 1;
 
name = "Thoths Metal Sheeting";
 
waitMinutes(10);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Sheeting.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Thoths_Metal_Sheeting.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function WaterMetalStrap()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 1;
 
name = "Water Metal Strap";
 
waitMinutes(1);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Straps.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Water_Metal_Strap.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function IronStrap()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 1;
 
name = "Iron Strap";
 
waitMinutes(3);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Straps.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Iron_Strap.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function AluminumStrap()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 1;
 
name = "Aluminum Strap";
 
waitMinutes(1);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Straps.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Aluminum_Strap.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
 
function CopperStrap()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 1;
 
name = "Copper Strap";
 
waitMinutes(2);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Straps.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Copper_Strap.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function IronPoker()
+
--Read Chat
num_loops = promptNumber("How many passes ?", 1);
+
ChatType = findchat();
batch = 1;
 
name = "Iron Poker";
 
waitMinutes(20);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Tools.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Iron_Poker.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function SteelBlade()
+
lsSleep(200);
num_loops = promptNumber("How many passes ?", 1);
 
batch = 1;
 
name = "Steel Blade";
 
waitMinutes(10);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Tools.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Steel_Blade.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
 
function LeadChisel()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 1;
 
name = "Lead Chisel";
 
waitMinutes(6);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Tools.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Lead_Chisel.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function ThothsMetalWire()
+
CurrentLure = string.sub(PlayersLures[CurrentLureIndex],string.find(PlayersLures[CurrentLureIndex],"_")+1,string.len(PlayersLures[CurrentLureIndex])-4);
num_loops = promptNumber("How many passes ?", 1);
 
batch = 14;
 
name = "Thoths Metal Wire";
 
waitMinutes(5);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Wire.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Thoths_Metal_Wire.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function MetalBlueWire()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 12;
 
name = "Metal Blue Wire";
 
waitMinutes(5);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Wire.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Metal_Blue_Wire.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function MagnesiumWire()
+
if ChatType == "nobitlostlure" then
num_loops = promptNumber("How many passes ?", 1);
+
--No fish bit. You also lost your lure.
batch = 10;
+
GrandTotalLostLures = GrandTotalLostLures + 1;
name = "Magnesium Wire";
+
GrandTotalFailed = GrandTotalFailed + 1;
waitMinutes(1);
+
--Reset, skip to next lure
for i=1, num_loops do
+
castcount=0;
while 1 do
+
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "No fish bit. You also lost your lure." .. "\n");
refreshWindows();
 
clickAllImages("Forge/Forge_Wire.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Magnesium_Wire.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function OctecsAlloyWire()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 16;
 
name = "Octecs Alloy Wire";
 
waitMinutes(10);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Wire.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Octecs_Alloy_Wire.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function SilverWire()
+
elseif ChatType == "nobit" then
num_loops = promptNumber("How many passes ?", 1);
+
--No fishbit
batch = 5;
+
GrandTotalFailed = GrandTotalFailed + 1;
name = "Silver Wire";
+
if LogFails == true then
waitMinutes(5);
+
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "No fish bit." .. "\n");
for i=1, num_loops do
+
end
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Wire.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Silver_Wire.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function CopperWire()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 20;
 
name = "Copper Wire";
 
waitMinutes(5);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Wire.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Copper_Wire.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function SteelWire()
+
elseif ChatType == "nocatchlostlure" then
num_loops = promptNumber("How many passes ?", 1);
+
--You didn't catch anything. You also lost your lure.
batch = 20;
+
GrandTotalLostLures = GrandTotalLostLures + 1;
name = "Steel Wire";
+
GrandTotalFailed = GrandTotalFailed + 1;
waitMinutes(5);
+
--Reset, skip to next lure
for i=1, num_loops do
+
castcount=0;
while 1 do
+
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "You didn\'t catch anything. You also lost your lure." .. "\n");
refreshWindows();
 
clickAllImages("Forge/Forge_Wire.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Steel_Wire.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
function GoldWire()
 
num_loops = promptNumber("How many passes ?", 1);
 
batch = 10;
 
name = "Gold Wire";
 
waitMinutes(10);
 
for i=1, num_loops do
 
while 1 do
 
refreshWindows();
 
clickAllImages("Forge/Forge_Wire.png");
 
lsSleep(400);
 
project_windows = clickAllImages("Forge/Forge_Gold_Wire.png");
 
if project_windows == 0 then
 
sleepWithStatus(1100, "Waiting for Project windows");
 
else
 
break;
 
end
 
end
 
waitGUI(i);
 
end
 
doneGUI(num_loops);
 
end
 
  
 +
elseif ChatType == "nocatch" then
 +
--You didn't catch anything.
 +
GrandTotalFailed = GrandTotalFailed + 1;
 +
if LogFails == true then
 +
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "You didn\'t catch anything." .. "\n");
 +
end
  
function Bars()
 
while 1 do
 
-- Ask for which button
 
local image_name = nil;
 
local is_done = nil;
 
while not is_done do
 
local y = nil;
 
local x = nil;
 
local bsize = nil;
 
for i=1, #bar_button_names do
 
if bar_button_names[i] == "Iron Bar" then
 
x = 30;
 
y = 10;
 
bsize = 250;
 
elseif bar_button_names[i] == "Gold Bar" then
 
x = 30;
 
y = 40;
 
bsize = 250;
 
elseif bar_button_names[i] == "Silver Bar" then
 
x = 30;
 
y = 70;
 
bsize = 250;
 
end
 
if lsButtonText(x, y, 0, bsize, 0x80D080ff, bar_button_names[i]) then
 
image_name = bar_button_names[i];
 
is_done = 1;
 
end
 
end
 
  
if lsButtonText(lsScreenX - 110, lsScreenY - 30, z, 100, 0xFFFFFFff, "End script") then
+
elseif ChatType == "alreadyfishing" then
error "Clicked End Script button";
+
--castcount = castcount-1;
end
+
lsSleep(15000); -- Long pause to wait for fishing queue to stop. Somehow it pushed the Fish button twice and now you will cast 2 times in a row.
lsDoFrame();
+
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "You are already fishing!" .. "\n");
lsSleep(10);
 
end
 
 
if image_name == "Iron Bar" then
 
IronBar();
 
elseif image_name == "Gold Bar" then
 
GoldBar();
 
elseif image_name == "Silver Bar" then
 
SilverBar();
 
end
 
end
 
end
 
  
function Sheeting()
 
while 1 do
 
-- Ask for which button
 
local image_name = nil;
 
local is_done = nil;
 
while not is_done do
 
local y = nil;
 
local x = nil;
 
local bsize = nil;
 
for i=1, #sheeting_button_names do
 
if sheeting_button_names[i] == "Lead Sheeting" then
 
x = 30;
 
y = 10;
 
bsize = 150;
 
elseif sheeting_button_names[i] == "Gold Sheeting" then
 
x = 30;
 
y = 35;
 
bsize = 150;
 
elseif sheeting_button_names[i] == "Copper Sheeting" then
 
x = 30;
 
y = 60;
 
bsize = 150;
 
        elseif sheeting_button_names[i] == "Treated Metal Sheeting" then
 
x = 30;
 
y = 285;
 
bsize = 150;
 
elseif sheeting_button_names[i] == "Octecs Alloy Sheeting" then
 
x = 30;
 
y = 85;
 
bsize = 150;
 
elseif sheeting_button_names[i] == "Silver Sheeting" then
 
x = 30;
 
y = 110;
 
bsize = 150;
 
elseif sheeting_button_names[i] == "Steel Sheeting" then
 
x = 30;
 
y = 135;
 
bsize = 150;
 
elseif sheeting_button_names[i] == "Gold Foil" then
 
x = 30;
 
y = 160;
 
bsize = 150;
 
elseif sheeting_button_names[i] == "Metal Blue Sheeting" then
 
x = 30;
 
y = 185;
 
bsize = 150;
 
elseif sheeting_button_names[i] == "Tin Sheeting" then
 
x = 30;
 
y = 210;
 
bsize = 150;
 
elseif sheeting_button_names[i] == "Moon Steel Sheeting" then
 
x = 30;
 
y = 235;
 
bsize = 150;
 
elseif sheeting_button_names[i] == "Thoths Metal Sheeting" then
 
x = 30;
 
y = 260;
 
bsize = 150;
 
end
 
if lsButtonText(x, y, 0, 250, 0x80D080ff, sheeting_button_names[i]) then
 
image_name = sheeting_button_names[i];
 
is_done = 1;
 
end
 
end
 
  
if lsButtonText(lsScreenX - 110, lsScreenY - 30, z, 100, 0xFFFFFFff, "End script") then
 
error "Clicked End Script button";
 
end
 
lsDoFrame();
 
lsSleep(10);
 
end
 
 
if image_name == "Lead Sheeting" then
 
LeadSheeting();
 
elseif image_name == "Gold Sheeting" then
 
GoldSheeting();
 
elseif image_name == "Copper Sheeting" then
 
CopperSheeting();
 
    elseif image_name == "Treated Metal Sheeting" then
 
TreatedSheeting();
 
elseif image_name == "Octecs Alloy Sheeting" then
 
OctecsAlloySheeting();
 
elseif image_name == "Silver Sheeting" then
 
SilverSheeting();
 
elseif image_name == "Steel Sheeting" then
 
SteelSheeting();
 
elseif image_name == "Gold Foil" then
 
GoldFoil();
 
elseif image_name == "Metal Blue Sheeting" then
 
MetalBlueSheeting();
 
elseif image_name == "Tin Sheeting" then
 
TinSheeting();
 
elseif image_name == "Moon Steel Sheeting" then
 
MoonSteelSheeting();
 
elseif image_name == "Thoths Metal Sheeting" then
 
ThothsMetalSheeting();
 
end
 
end
 
  
 +
elseif ChatType == "strange" then
 +
--Strange Fish
 +
GrandTotalStrange = GrandTotalStrange + 1;
 +
GrandTotalFailed = GrandTotalFailed + 1;
 +
if LogStrangeUnusual == true then
 +
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "You almost caught a STRANGE fish, but your rod was just too clumbsy." .. "\n");
 +
end
  
end
+
-- if AlmostCaughtAttempts > 0 then
 +
-- strangecounter = strangecounter +1;
 +
-- end
 +
 +
 +
elseif ChatType == "strangelostlure" then
 +
-- Strange Fish and lost lure
 +
GrandTotalStrange = GrandTotalStrange + 1;
 +
GrandTotalLostLures = GrandTotalLostLures + 1;
 +
GrandTotalFailed = GrandTotalFailed + 1;
 +
--Reset, skip to next lure
 +
castcount=0;
 +
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "You almost caught a STRANGE fish, but your rod was just too clumbsy. You also lost your lure." .. "\n");
  
function Straps()
+
-- if AlmostCaughtAttempts > 0 then
while 1 do
+
-- strangecounter = strangecounter +1;
-- Ask for which button
+
-- end
local image_name = nil;
 
  
  
local is_done = nil;
 
while not is_done do
 
local y = nil;
 
local x = nil;
 
local bsize = nil;
 
for i=1, #straps_button_names do
 
if straps_button_names[i] == "Water Metal Strap" then
 
x = 30;
 
y = 10;
 
bsize = 250;
 
elseif straps_button_names[i] == "Iron Strap" then
 
x = 30;
 
y = 40;
 
bsize = 250;
 
elseif straps_button_names[i] == "Aluminum Strap" then
 
x = 30;
 
y = 70;
 
bsize = 250;
 
elseif straps_button_names[i] == "Copper Strap" then
 
x = 30;
 
y = 100;
 
bsize = 250;
 
end
 
if lsButtonText(x, y, 0, bsize, 0x80D080ff, straps_button_names[i]) then
 
image_name = straps_button_names[i];
 
is_done = 1;
 
end
 
end
 
  
if lsButtonText(lsScreenX - 110, lsScreenY - 30, z, 100, 0xFFFFFFff, "End script") then
+
elseif ChatType == "unusual" then
error "Clicked End Script button";
+
-- Unusual Fish
end
+
GrandTotalUnusual = GrandTotalUnusual + 1;
lsDoFrame();
+
GrandTotalFailed = GrandTotalFailed + 1;
lsSleep(10);
+
if LogStrangeUnusual == true then
end
+
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "You almost caught an UNUSUAL fish, but you were not quick enough." .. "\n");
+
end
if image_name == "Water Metal Strap" then
 
WaterMetalStrap();
 
elseif image_name == "Iron Strap" then
 
IronStrap();
 
elseif image_name == "Aluminum Strap" then
 
AluminumStrap();
 
elseif image_name == "Copper Strap" then
 
CopperStrap();
 
end
 
end
 
end
 
  
function Tools()
+
-- if AlmostCaughtAttempts > 0 then
while 1 do
+
-- strangecounter = strangecounter +1;
-- Ask for which button
+
-- end
local image_name = nil;
 
local is_done = nil;
 
while not is_done do
 
local y = nil;
 
local x = nil;
 
local bsize = nil;
 
for i=1, #tools_button_names do
 
if tools_button_names[i] == "Iron Poker" then
 
x = 30;
 
y = 10;
 
bsize = 250;
 
elseif tools_button_names[i] == "Steel Blade" then
 
x = 30;
 
y = 40;
 
bsize = 250;
 
elseif tools_button_names[i] == "Lead Chisel" then
 
x = 30;
 
y = 70;
 
bsize = 250;
 
end
 
if lsButtonText(x, y, 0, bsize, 0x80D080ff, tools_button_names[i]) then
 
image_name = tools_button_names[i];
 
is_done = 1;
 
end
 
end
 
  
if lsButtonText(lsScreenX - 110, lsScreenY - 30, z, 100, 0xFFFFFFff, "End script") then
 
error "Clicked End Script button";
 
end
 
lsDoFrame();
 
lsSleep(10);
 
end
 
 
if image_name == "Iron Poker" then
 
IronPoker();
 
elseif image_name == "Steel Blade" then
 
SteelBlade();
 
elseif image_name == "Lead Chisel" then
 
LeadChisel();
 
end
 
end
 
end
 
  
function Wire()
 
while 1 do
 
-- Ask for which button
 
local image_name = nil;
 
local is_done = nil;
 
while not is_done do
 
local y = nil;
 
local x = nil;
 
local bsize = nil;
 
for i=1, #wire_button_names do
 
if wire_button_names[i] == "Thoths Metal Wire" then
 
x = 30;
 
y = 10;
 
bsize = 150;
 
elseif wire_button_names[i] == "Metal Blue Wire" then
 
x = 30;
 
y = 35;
 
bsize = 150;
 
elseif wire_button_names[i] == "Magnesium Wire" then
 
x = 30;
 
y = 60;
 
bsize = 150;
 
elseif wire_button_names[i] == "Octecs Alloy Wire" then
 
x = 30;
 
y = 85;
 
bsize = 150;
 
elseif wire_button_names[i] == "Silver Wire" then
 
x = 30;
 
y = 110;
 
bsize = 150;
 
elseif wire_button_names[i] == "Copper Wire" then
 
x = 30;
 
y = 135;
 
bsize = 150;
 
elseif wire_button_names[i] == "Steel Wire" then
 
x = 30;
 
y = 160;
 
bsize = 150;
 
elseif wire_button_names[i] == "Gold Wire" then
 
x = 30;
 
y = 185;
 
bsize = 150;
 
end
 
if lsButtonText(x, y, 0, 250, 0x80D080ff, wire_button_names[i]) then
 
image_name = wire_button_names[i];
 
is_done = 1;
 
end
 
end
 
  
if lsButtonText(lsScreenX - 110, lsScreenY - 30, z, 100, 0xFFFFFFff, "End script") then
 
error "Clicked End Script button";
 
end
 
lsDoFrame();
 
lsSleep(10);
 
end
 
 
if image_name == "Thoths Metal Wire" then
 
ThothsMetalWire();
 
elseif image_name == "Metal Blue Wire" then
 
MetalBlueWire();
 
elseif image_name == "Magnesium Wire" then
 
MagnesiumWire();
 
elseif image_name == "Octecs Alloy Wire" then
 
OctecsAlloyWire();
 
elseif image_name == "Silver Wire" then
 
SilverWire();
 
elseif image_name == "Copper Wire" then
 
CopperWire();
 
elseif image_name == "Steel Wire" then
 
SteelWire();
 
elseif image_name == "Gold Wire" then
 
GoldWire();
 
end
 
end
 
end
 
</pre>
 
{{Collapse bottom}}
 
  
{{Collapse top|title=VT Barley with Skip Water}}
+
-- Can't uncomment below elseif statement until we get a screenshot of a message of you were not quick enough. You also lost your lure.
<pre>
+
-- This would need to be added to Fishing_Func.inc , in the Chat_Types {array} along with adding Chatlog_AlmostUnusualLostlure.png). Add above "unusual" line in the array
  
-- Edit these first 2 to adjust how much is planted in a pass
 
-- May need to adjust walk_time in Barley_common.inc if you move too slowly to keep up
 
-- grids tested: 2x2, 3x3, 5x5, 6x6 (probably need 3+ dex and 600ms walk time)
 
grid_w = 5;
 
grid_h = 5;
 
watered = {};
 
loop_count = 0;
 
skip_water = 0;
 
  
loadfile("luaScripts/Flax_common.inc")();
+
--elseif ChatType == "unusuallostlure" then
loadfile("luaScripts/screen_reader_common.inc")();
+
-- Unusual Fish
loadfile("luaScripts/ui_utils.inc")();
+
--GrandTotalUnusual = GrandTotalUnusual + 1;
 +
--GrandTotalLostLures = GrandTotalLostLures + 1;
 +
--GrandTotalFailed = GrandTotalFailed + 1;
 +
--if LogStrangeUnusual == true then
 +
--WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "You almost caught an UNUSUAL fish, but you were not quick enough." .. "\n");
 +
--end
  
  
function promptBarleyNumbers(is_plant)
 
scale = 1.0;
 
 
local z = 0;
 
local is_done = nil;
 
local value = nil;
 
-- Edit box and text display
 
while not is_done do
 
-- Put these everywhere to make sure we don't lock up with no easy way to escape!
 
checkBreak("disallow pause");
 
 
lsPrint(10, 10, z, scale, scale, 0xFFFFFFff, "Choose passes and grid size");
 
 
-- lsEditBox needs a key to uniquely name this edit box
 
--  let's just use the prompt!
 
-- lsEditBox returns two different things (a state and a value)
 
local y = 40;
 
lsPrint(5, y, z, scale, scale, 0xFFFFFFff, "Passes:");
 
is_done, num_loops = lsEditBox("passes",
 
100, y, z, 50, 30, scale, scale,
 
0x000000ff, 1);
 
if not tonumber(num_loops) then
 
is_done = nil;
 
lsPrint(10, y+18, z+10, 0.7, 0.7, 0xFF2020ff, "MUST BE A NUMBER");
 
num_loops = 1;
 
end
 
y = y + 32;
 
  
lsPrint(5, y, z, scale, scale, 0xFFFFFFff, "Grid size:");
+
-- if AlmostCaughtAttempts > 0 then
is_done, grid_w = lsEditBox("grid",
+
-- strangecounter = strangecounter +1;
100, y, z, 50, 30, scale, scale,
+
-- end
0x000000ff, grid_w);
 
if not tonumber(grid_w) then
 
is_done = nil;
 
lsPrint(10, y+18, z+10, 0.7, 0.7, 0xFF2020ff, "MUST BE A NUMBER");
 
grid_w = 1;
 
grid_h = 1;
 
end
 
  
grid_w = tonumber(grid_w);
 
grid_h = grid_w;
 
y = y + 32;
 
  
if lsButtonText(170, y-32, z, 100, 0xFFFFFFff, "OK") then
 
is_done = 1;
 
end
 
  
if is_plant then
 
lsPrintWrapped(10, y, z+10, lsScreenX - 20, 0.7, 0.7, 0xD0D0D0ff, "This will plant and harvest a " .. grid_w .. "x" .. grid_w .. " grid of Barley " .. num_loops .. " times, requiring " .. (grid_w * grid_w) .. " raw barley and ".. (grid_w * grid_w * num_loops * 4) .. "water in jugs, doing " .. (grid_w*grid_w*num_loops) .. " harvests.");
 
else
 
lsPrintWrapped(10, y, z+10, lsScreenX - 20, 0.7, 0.7, 0xD0D0D0ff, "This will plant a " .. grid_w .. "x" .. grid_w .. " grid of Flax " .. num_loops .. " times, requiring " .. (grid_w * grid_w) .. " seeds, yielding " .. (grid_w * grid_w * num_loops) .. " seeds.");
 
end
 
y = y + 50;
 
skip_water = lsCheckBox(10, y, z, 0xFFFFFFff, "Skip Rain Barrel", skip_water);
 
  
if is_done and (not num_loops or not grid_w) then
+
elseif ChatType == "odd" then
error 'Canceled';
+
-- Odd Fish
end
+
GrandTotalOdd = GrandTotalOdd + 1;
+
GrandTotalFailed = GrandTotalFailed + 1;
if lsButtonText(lsScreenX - 110, lsScreenY - 30, z, 100, 0xFFFFFFff, "End script") then
+
if LogOdd == true then
error "Clicked End Script button";
+
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "You almost caught an ODD fish, but were too late recognizing the bite." .. "\n");
end
+
end
 
 
lsDoFrame();
 
lsSleep(10); -- Sleep just so we don't eat up all the CPU for no reason
 
end
 
end
 
  
  
function doit()
+
elseif ChatType == "oddlostlure" then
 +
-- Odd Fish and lost lure
 +
GrandTotalOdd = GrandTotalOdd + 1;
 +
GrandTotalLostLures = GrandTotalLostLures + 1;
 +
GrandTotalFailed = GrandTotalFailed + 1;
 +
--Reset, skip to next lure
 +
castcount=0;
 +
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "You almost caught an ODD fish, but were too late recognizing the bite. You also lost your lure." .. "\n");
  
  promptBarleyNumbers(1);
 
  askForWindow("Make sure the plant barley window is pinned and you are 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.");
 
  lsSleep(1000);
 
  delay_time = 2000;
 
  local x = 1;
 
  local y = 1;
 
  initGlobals();
 
  -- Find the plant barley button
 
  srReadScreen();
 
  
  local imgBarley = "barley.png";
 
  local xyPlantBarley = srFindImage(imgBarley);
 
  if not xyPlantBarley then
 
    error 'Could not find plant window';
 
  end
 
  xyPlantBarley[0] = xyPlantBarley[0] + 5;
 
 
 
  -- Find the Rain Barrel
 
  if not skip_water then
 
local imgDrawWater = "draw_water.png";
 
local xyDrawWater = srFindImage(imgDrawWater);
 
if not xyDrawWater then
 
error 'Could not find rain barrel';
 
end
 
xyDrawWater[0] = xyDrawWater[0] + 5;
 
  end
 
  
 
  
  for loop_count=1, num_loops do
+
elseif ChatType == "carry" then
    local start_time = lsGetTimer();
+
--chat lines are messed up now
    harvested = 0;
+
castcount=0;
    -- Init watered array to 0
+
    for y=grid_h, 1, -1 do
 
      for x=grid_w, 1, -1 do
 
        watered[x+((y-1)*grid_w)] = 1;
 
      end
 
    end
 
  -- Local variables
 
    local xyCenter = getCenterPos();
 
    local xyBarleyMenu = {};
 
    xyBarleyMenu[0] = xyCenter[0] - 43;
 
    xyBarleyMenu[1] = xyCenter[1] + 0;
 
    local dxi=1;
 
    local dt_max=grid_w;
 
    local dt=grid_w;
 
    local dx={1, 0, -1, 0};
 
    local dy={0, -1, 0, 1};
 
    local num_at_this_length = 3;
 
    local x_pos = 0;
 
    local y_pos = 0;
 
    for y=1, grid_h do
 
      for x=1, grid_w do
 
        lsPrintln('doing ' .. x .. ',' .. y .. ' of ' .. grid_w .. ',' .. grid_h);
 
        statusScreen("Planting " .. x .. ", " .. y);
 
       
 
        -- Plant
 
        lsPrintln('planting ' .. xyPlantBarley[0] .. ',' .. xyPlantBarley[1]);
 
        setWaitSpot(xyBarleyMenu[0], xyBarleyMenu[1]);
 
        srClickMouseNoMove(xyPlantBarley[0], xyPlantBarley[1], 0);
 
        srSetMousePos(xyBarleyMenu[0], xyBarleyMenu[1]);
 
        waitForChange();
 
       
 
        -- Bring up menu
 
        lsPrintln('menu ' .. xyBarleyMenu[0] .. ',' .. xyBarleyMenu[1]);
 
        setWaitSpot(xyBarleyMenu[0]+5, xyBarleyMenu[1]);
 
        srClickMouse(xyBarleyMenu[0], xyBarleyMenu[1], 0);
 
        waitForChange();
 
  
        -- Check for window size
+
elseif ChatType == "caught" or ChatType == "caughtlostlure" then
        window_w = 214;
+
Fish = ChatReadFish();
        window_h = 218;
 
  
        -- Pin
+
table.insert(gui_log_fish,Fish);
        lsPrintln('pin ' .. (xyBarleyMenu[0]+5) .. ',' .. xyBarleyMenu[1]);
 
        srClickMouseNoMove(xyBarleyMenu[0]+5, xyBarleyMenu[1]+0, 1);
 
  
        -- Move window
 
        local pp = pinnedPos(x, y);
 
        lsPrintln('move ' .. (xyBarleyMenu[0]+5) .. ',' .. xyBarleyMenu[1] .. ' to ' .. pp[0] .. ',' .. pp[1]);
 
        drag(xyBarleyMenu[0] + 5, xyBarleyMenu[1], pp[0], pp[1], 0);
 
 
        -- Add 2 water now
 
        srReadScreen();
 
        local barleyAddButton = srFindImageInRange("BarleyAdd.png", pp[0], pp[1], 200, 100);
 
        local barleyWater = srFindImageInRange("barleyWater.png", pp[0], pp[1] - 50, 220, 150);
 
        if not barleyAddButton or not barleyWater then
 
          -- bugfix maybe for lag.
 
          lsSleep(100);
 
          srReadScreen();
 
          barleyAddButton = srFindImageInRange("BarleyAdd.png", pp[0], pp[1], 200, 100);
 
          barleyWater = srFindImageInRange("barleyWater.png", pp[0], pp[1] - 50, 220, 150);
 
        end
 
  
        srClickMouseNoMove(barleyAddButton[0]+8, barleyWater[1]);
+
if ChatType == "caughtlostlure" then
        srClickMouseNoMove(barleyAddButton[0]+8, barleyWater[1]);
+
GrandTotalLostLures = GrandTotalLostLures + 1;
        watered[x+((y-1)*grid_w)] = watered[x+((y-1)*grid_w)] + 2;
+
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "Though you lost your lure, you did catch a " .. Fish .. "\n");
 +
-- This Needs Check for new lure. This will cause a error if not.
 +
--Reset, skip to next lure
 +
castcount=0;
 +
else
 +
WriteFishLog("[" .. CurrentTime .. "]\t[" .. CurrentLure .. "]\t" .. "Caught a " .. Fish .. "\n");
  
        -- move to next position
+
end
        if not ((x == grid_w) and (y == grid_h)) then
+
          lsPrintln('walking dx=' .. dx[dxi] .. ' dy=' .. dy[dxi]);
+
--gui_refresh();
          x_pos = x_pos + dx[dxi];
+
          y_pos = y_pos + dy[dxi];
+
if SkipCommon == true then
          srClickMouseNoMove(xyCenter[0] + walk_px_x*dx[dxi], xyCenter[1] + walk_px_y*dy[dxi], 0);
+
FishType = string.sub(Fish,string.find(Fish,",") + 1);
          lsSleep(walk_time);
+
if FishType == "Abdju" or FishType == "Chromis" or FishType == "Catfish" or FishType == "Carp" or FishType == "Perch" or FishType == "Phagrus" or FishType == "Tilapia" then
          dt = dt - 1;
+
--Skip it
          if dt == 1 then
+
castcount=0;
            dxi = dxi + 1;
 
            num_at_this_length = num_at_this_length - 1;
 
            if num_at_this_length == 0 then
 
              dt_max = dt_max - 1;
 
              num_at_this_length = 2;
 
            end
 
            if dxi == 5 then
 
              dxi = 1;
 
            end
 
            dt = dt_max;
 
          else
 
            lsPrintln('skipping walking, on last leg');
 
          end
 
        end
 
        checkBreak();
 
      end
 
    end
 
 
 
    statusScreen("Refocusing windows...");
 
    -- Bring windows to front
 
    for y=grid_h, 1, -1 do
 
      for x=grid_w, 1, -1 do
 
        local rp = refreshPosUp(x, y);
 
        srClickMouseNoMove(rp[0], rp[1], 0);
 
        lsSleep(refocus_click_time);
 
      end
 
    end
 
    lsSleep(refocus_time); -- Wait for last window to bring to the foreground before clicking again
 
 
 
    -- Barley has been planted, pinned and refocused
 
 
    while 1 do
 
      for y=1, grid_h do
 
        for x=1, grid_w do
 
          local pp = pinnedPos(x, y);
 
          local rp = refreshPosDown(x, y);
 
          srClickMouse(rp[0],rp[1]);
 
          lsSleep(200);
 
          srReadScreen();
 
          local leftBar = srFindImageInRange("barleyBarLeft.png", pp[0], pp[1] - 50, 120, 100);
 
          if leftBar then
 
            leftBar[0] = leftBar[0] + 4;
 
          end
 
          local rightBar = srFindImageInRange("barleyBarRight.png", pp[0], pp[1] - 50, 220, 200);
 
          if rightBar then
 
            rightBar[0] = rightBar[0] + 1;
 
          end
 
          if not rightBar then
 
            error 'Could not find rightbar';
 
          end
 
          local barleyWater = srFindImageInRange("barleyWater.png", pp[0], pp[1] - 50, 220, 150);
 
          if not barleyWater then error 'Could not find water button.'; end
 
          local barleyAddButton = srFindImageInRange("BarleyAdd.png", pp[0], pp[1], 200, 100);
 
          if not barleyAddButton then error 'Could not find add button. Ended at batch '; end
 
  
          while 1 do
+
end
            if leftBar then
+
end
              waterBlue = 0;
+
              if rightBar then
+
gui_refresh();
                if barleyWater then
+
end
                  srReadScreen();
 
                  for i=leftBar[0],rightBar[0] do
 
                    pxval = srReadPixelFromBuffer(i, barleyWater[1]);
 
                    b = (math.floor(pxval/256) % 256);
 
                    if b > 220 then
 
                      waterBlue = waterBlue + 1;
 
                    end
 
                  end
 
                  waterBlue = (waterBlue/(rightBar[0]-leftBar[0])*100);
 
                end
 
              end
 
            end
 
            checkBreak();
 
 
 
            if watered[x+((y-1)*grid_w)] < 5 then
+
gui_refresh();
              statusScreen("Watering " .. x .. "," .. y .. "step " .. watered[x+((y-1)*grid_w)] .. ".");
+
end
              if waterBlue < 90 then
+
                if watered[x+((y-1)*grid_w)] == 0 then
+
gui_refresh();
                end
 
                srClickMouseNoMove(barleyAddButton[0]+8, barleyWater[1]);
 
                watered[x+((y-1)*grid_w)] = watered[x+((y-1)*grid_w)] + 1;
 
                lsSleep(100);
 
                break;
 
              end
 
            else
 
              statusScreen("Harvesting " .. x .. "," .. y .. ".");
 
              if waterBlue < 90 then
 
                srClickMouseNoMove(pp[0]+90, pp[1]+90);
 
                lsSleep(100);
 
                srClickMouseNoMove(pp[0]+180, pp[1]-25);
 
                if watered[x+((y-1)*grid_w)] == 5 then
 
                  harvested = 1;
 
                end
 
                break;
 
              end
 
            end
 
          end
 
        end
 
      end
 
 
 
      if harvested == 0 then
 
        statusScreen("Refocusing windows...");
 
        -- Bring windows to front
 
        for y=grid_h, 1, -1 do
 
          for x=grid_w, 1, -1 do
 
            local rp = refreshPosUp(x, y);
 
            srClickMouseNoMove(rp[0], rp[1], 0);
 
            lsSleep(refocus_click_time);
 
          end
 
        end
 
        lsSleep(refocus_time); -- Wait for last window to bring to the foreground before clicking again
 
      else
 
        for x=1, x_pos do
 
          srClickMouseNoMove(xyCenter[0] + walk_px_x*-1, xyCenter[1], 0);
 
          lsSleep(walk_time);
 
        end
 
        for x=1, -y_pos do
 
          srClickMouseNoMove(xyCenter[0], xyCenter[1] + walk_px_y, 0);
 
          lsSleep(walk_time);
 
        end
 
        break;
 
      end
 
    end
 
    local end_time = lsGetTimer();
 
    statusScreen("Time taken: " .. (end_time-start_time)/1000);
 
    -- move X and Y every 4 batches, but skip the Y move every 20th batch
 
    if loop_count % 4 == 0 and loop_count % 5 == 0 then
 
      doCorrectiveMove('x')
 
    elseif loop_count % 4 == 0 then
 
      doCorrectiveMove('xy')
 
    end
 
    --doStashWH(num_loops*grid_w*grid_w);
 
    --doRefillWater(4*numloops*grid_w*grid_w);
 
    doStashWH(grid_w*grid_w);
 
if not skip_water then
 
doRefillWater(4*grid_w*grid_w);
 
 
end
 
end
    debug('end of batch #' .. loop_count)
 
  end
 
 
end
 
end
 +
</pre>
 +
{{Collapse bottom}}
 +
 +
{{Collapse top|title=New Raeli Oven Monitor (IN TESTING v3)}}
 +
<pre>
 +
loadfile("luaScripts/screen_reader_common.inc")();
 +
loadfile("luaScripts/common.inc")();
 +
loadfile("luaScripts/ui_utils.inc")();
  
function doCorrectiveMove(move)
+
askText = singleLine([[
   statusScreen("Moving to correct for drift");
+
   Raeli Color Monitor v1.1c (edit by Selune) --
   local xyCenter = getCenterPos();
+
   Make sure the Raeli Oven is pinned, select the ATITD window, and press shift.
  if move == 'xy' or move == 'x' then
+
]]);
    srClickMouseNoMove(xyCenter[0] + walk_px_x*-1, xyCenter[1], 0);
 
    lsSleep(walk_time);
 
  end
 
  if move == 'xy' or move == 'y' then
 
    srClickMouseNoMove(xyCenter[0], xyCenter[1] + walk_px_y, 0);
 
    lsSleep(walk_time);
 
  end
 
end
 
  
function doStashWH(qty)
+
stop_at_CB = false;
  local wh = srFindImage("stash.png");
+
take_screenshots = true;
  if wh then
+
stop_at_color = "White";
    srClickMouseNoMove(wh[0]+9,wh[1]+9)
+
confidence_threshold = 15;
    debug('found stash, clicked it');
+
saved_x = 0;
    lsSleep(250);
+
saved_y = 0;
 +
go_now = false;
  
    srReadScreen();
+
color_names = {"AliceBlue", "AntiqueWhite", "Aqua", "Aquamarine", "Azure", "Beige", "Bisque", "Black", "BlanchedAlmond", "Blue", "BlueViolet", "Brown", "Burlywood", "CadetBlue", "Carrot", "Chartreuse", "Chocolate", "Coral", "CornflowerBlue", "Cornsilk", "Crimson", "DarkBlue", "DarkCyan", "DarkGoldenrod", "DarkGray", "DarkGreen", "DarkKhaki", "DarkMagenta", "DarkOliveGreen", "DarkOrange", "DarkOrchid", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue", "DarkSlateGray", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue", "DimGray", "DodgerBlue", "Feldspar", "FireBrick", "FloralWhite", "ForestGreen", "Fuchsia", "Gainsboro", "GhostWhite", "Gold", "Goldenrod", "Gray", "Green", "GreenYellow", "Honeydew", "HotPink", "IndianRed", "Indigo", "Ivory", "Khaki", "Lavender", "LavenderBlush", "LawnGreen", "LemonChiffon", "LightBlue", "LightCoral", "LightCyan", "LightGoldenrodYellow", "LightGreen", "LightGrey", "LightPink", "LightSalmon", "LightSeaGreen", "LightSkyBlue", "LightSlateBlue", "LightSlateGray", "LightSteelBlue", "LightYellow", "Lime", "LimeGreen", "Linen", "Maroon ", "MediumAquamarine", "MediumBlue ", "MediumOrchid", "MediumPurple", "MediumSeaGreen", "MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise", "MediumVioletRed", "MidnightBlue", "MintCream", "MistyRose", "Moccasin", "NavajoWhite", "Navy ", "OldLace", "Olive", "OliveDrab", "Orange", "OrangeRed", "Orchid", "PaleGoldenrod", "PaleGreen", "PaleTurquoise", "PaleVioletRed", "PapayaWhip", "PeachPuff", "Peru", "Pink", "Plum", "PowderBlue", "Purple ", "Red", "RosyBrown", "RoyalBlue", "SaddleBrown", "Salmon", "SandyBrown", "SeaGreen", "Seashell", "Sienna", "Silver", "SkyBlue", "SlateBlue", "SlateGray", "Snow", "SpringGreen", "SteelBlue ", "Tan", "Teal", "Thistle", "Tomato", "Turquoise", "Violet", "VioletRed", "Wheat", "White", "WhiteSmoke", "Yellow", "YellowGreen"};
    local insects = srFindImage("stashInsectEllipsis.png");
+
color_values = {0xF0F8FF, 0xFAEBD7, 0x00FFFF, 0x7FFFD4, 0xF0FFFF, 0xF5F5DC, 0xFFE4C4, 0x000000, 0xFFEBCD, 0x0000FF, 0x8A2BE2, 0xA52A2A, 0xDEB887, 0x5F9EA0, 0xE07020, 0x7FFF00, 0xD2691E, 0xFF7F50, 0x6495ED, 0xFFF8DC, 0xDC143C, 0x00008B, 0x008B8B, 0xB8860B, 0xA9A9A9, 0x006400, 0xBDB76B, 0x8B008B, 0x556B2F, 0xFF8C00, 0x9932CC, 0x8B0000, 0xE9967A, 0x8FBC8F, 0x483D8B, 0x2F4F4F, 0x00CED1, 0x9400D3, 0xFF1493, 0x00BFFF, 0x696969, 0x1E90FF, 0xD19275, 0xB22222, 0xFFFAF0, 0x228B22, 0xFF00FF, 0xDCDCDC, 0xF8F8FF, 0xFFD700, 0xDAA520, 0x808080, 0x008000, 0xADFF2F, 0xF0FFF0, 0xFF69B4, 0xCD5C5C, 0x4B0082, 0xFFFFF0, 0xF0E68C, 0xE6E6FA, 0xFFF0F5, 0x7CFC00, 0xFFFACD, 0xADD8E6, 0xF08080, 0xE0FFFF, 0xFAFAD2, 0x90EE90, 0xD3D3D3, 0xFFB6C1, 0xFFA07A, 0x20B2AA, 0x87CEFA, 0x8470FF, 0x778899, 0xB0C4DE, 0xFFFFE0, 0x00FF00, 0x32CD32, 0xFAF0E6, 0x800000, 0x66CDAA, 0x0000CD, 0xBA55D3, 0x9370DB, 0x3CB371, 0x7B68EE, 0x00FA9A, 0x48D1CC, 0xC71585, 0x191970, 0xF5FFFA, 0xFFE4E1, 0xFFE4B5, 0xFFDEAD, 0x000080, 0xFDF5E6, 0x808000, 0x6B8E23, 0xFFA500, 0xFF4500, 0xDA70D6, 0xEEE8AA, 0x98FB98, 0xAFEEEE, 0xDB7093, 0xFFEFD5, 0xFFDAB9, 0xCD853F, 0xFFC0CB, 0xDDA0DD, 0xB0E0E6, 0x800080, 0xFF0000, 0xBC8F8F, 0x4169E1, 0x8B4513, 0xFA8072, 0xF4A460, 0x2E8B57, 0xFFF5EE, 0xA0522D, 0xC0C0C0, 0x87CEEB, 0x6A5ACD, 0x708090, 0xFFFAFA, 0x00FF7F, 0x4682B4, 0xD2B48C, 0x008080, 0xD8BFD8, 0xFF6347, 0x40E0D0, 0xEE82EE, 0xD02090, 0xF5DEB3, 0xFFFFFF, 0xF5F5F5, 0xFFFF00, 0x9ACD32};
  
     local stashes = srFindImage("stashBarley.png");
+
-- Decimal to Hex conversion
     if not stashes then
+
function DEC_HEX(IN)
      error "no barley to stash"
+
     local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
 +
     while IN>0 do
 +
        I=I+1
 +
        IN,D=math.floor(IN/B),math.mod(IN,B)+1
 +
        OUT=string.sub(K,D,D)..OUT
 
     end
 
     end
     srClickMouseNoMove(stashes[0],stashes[1]);
+
     return OUT
 +
end
  
    lsSleep(250);
+
--Color Conversions
     -- stash exactly the right amount by number so we don't lose our seed barley
+
function rgb2hsl(src_r, src_g, src_b)
    srKeyEvent(qty);
+
local h, s, l, d;
     srKeyEvent('\n');
+
src_r = src_r / 255;
 +
src_g = src_g / 255;
 +
src_b = src_b / 255;
 +
     local max_rgb = math.max(src_r, src_g, src_b);
 +
local min_rgb = math.min(src_r, src_g, src_b);
 +
     l = (max_rgb + min_rgb) / 2;
  
     if insects then
+
     if(max_rgb == min_rgb) then
      srClickMouseNoMove(wh[0]+9,wh[1]+9)
+
        h = 0; --achromatic
      lsSleep(250);
+
s = 0;
      srReadScreen();
+
    else
 
+
        d = max_rgb - min_rgb;
      local insects = srFindImage("stashInsectEllipsis.png");
+
if l > 0.5 then
      if insects then
+
s = d / (2 - max_rgb - min_rgb);
        srClickMouseNoMove(insects[0],insects[1]);
+
else
        lsSleep(250);
+
s = d / (max_rgb + min_rgb);
 
+
end
        srReadScreen();
+
        insects = srFindImage("stashAllTheInsects.png");
+
if src_g > src_b then
        if not insects then
+
if src_r > src_g then
          error "found insects but couldn't stash them";
+
h = (src_g - src_b) / d;
        end
+
else
        srClickMouseNoMove(insects[0],insects[1]);
+
h = (src_b - src_r) / d + 2;
      end
+
end
 +
else
 +
if src_r > src_g then
 +
h = (src_g - src_b) / d + 6;
 +
else
 +
h = (src_r - src_g) / d + 4;
 +
end
 +
end
 +
        h = h / 6;
 
     end
 
     end
  end
 
end
 
 
function doRefillWater(qty)
 
  debug("in refill")
 
  local rb = srFindImage("draw_water.png");
 
  if rb then
 
    srClickMouseNoMove(rb[0]+5,rb[1]+5)
 
    lsSleep(250);
 
    srKeyEvent(qty);
 
    srKeyEvent('\n');
 
  end
 
  
 +
if h == nil then
 +
error "NO H";
 +
end
 +
 +
if s == nil then
 +
error ("NO S  D:" .. d);
 +
end
 +
 +
if l == nil then
 +
error "NO L";
 +
end
 +
 +
    return h, s, l;
 
end
 
end
  
 
+
function rgb2lab(src_r, src_g, src_b)
function debug(msg)
+
--R from 0 to 255
  if 0 then
+
--G from 0 to 255
    statusScreen(msg);
+
--B from 0 to 255
    lsSleep(1000);
+
local r = src_r/255;
  end  
+
local g = src_g/255;
 +
local b = src_b/255;
 +
 +
if (r > 0.04045) then
 +
r = math.pow((r + 0.055) / 1.055, 2.4);
 +
else
 +
r = r / 12.92;
 +
end
 +
if ( g > 0.04045) then
 +
g = math.pow((g + 0.055) / 1.055, 2.4);
 +
else
 +
g = g / 12.92;
 +
end
 +
if (b > 0.04045) then
 +
b = math.pow((b + 0.055) / 1.055, 2.4);
 +
else
 +
b = b / 12.92;
 +
end
 +
 +
r = r * 100;
 +
g = g * 100;
 +
b = b * 100;
 +
 +
local x = r * 0.4124 + g * 0.3576 + b * 0.1805;
 +
local y = r * 0.2126 + g * 0.7152 + b * 0.0722;
 +
local z = r * 0.0193 + g * 0.1192 + b * 0.9505;
 +
 +
x = x / 95.047;
 +
y = y / 100.000; 
 +
z = z / 108.883;
 +
 +
if ( x > 0.008856 ) then
 +
x = math.pow( x , 1/3 );
 +
else
 +
x = ( 7.787 * x ) + ( 16/116 );
 +
end
 +
if ( y > 0.008856 ) then
 +
y = math.pow( y , 1/3 );
 +
else
 +
y = ( 7.787 * y ) + ( 16/116 );
 +
end
 +
if ( z > 0.008856 ) then
 +
z = math.pow( z , 1/3 );
 +
else
 +
z = ( 7.787 * z ) + ( 16/116 );
 +
end
 +
 +
local lab_l = ( 116 * y ) - 16;
 +
local lab_a = 500 * ( x - y );
 +
local lab_b = 200 * ( y - z );
 +
 +
return lab_l, lab_a, lab_b;
 
end
 
end
</pre>
 
{{Collapse bottom}}
 
 
{{Collapse top|title=Hackling Rake Fixed}}
 
<pre>
 
-- Hackling Rake - Original macro by Bardoth (T6) - Revised by Cegaiel
 
-- Runs the Hacking Rake (or Flax Comb). Monitors the skills tab and only clicks when its all black.
 
--
 
--
 
 
assert(loadfile("luaScripts/common.inc"))();
 
 
askText = singleLine([[
 
Hackling Rake v1.0 (by Bardoth - Revised by Cegaiel) --
 
Pin Hacking Rake or Flax Comb window up and have Rotten Flax in you inventory. Make sure your rake is on the first step before starting. You MUST have Skills window open and everything from Strength to Perception skill should be visible.
 
Press Shift to continue.
 
]]);
 
 
do_click_refresh = 1;
 
do_click_refresh_when_end_red = 1;
 
improved_rake = 0;
 
num_flax = 0;
 
num_loops = 0;
 
per_rake = 10;
 
  
function promptRakeNumbers()
+
--Get nearest color name
scale = 1.0;
+
function nearestColor(px)
 +
local rgb_r, rgb_g, rgb_b, tst_r, tst_g, tst_b, test_px;
 +
local lab_l, lab_a, lab_b, lab_tst_l, lab_tst_a, lab_tst_b;
 +
local hsl_h, hsl_s, hsl_l, hsl_tst_h, hsl_tst_s, hsl_tst_l;
 +
local offset, best_name, best_offset, next_best_offset, confidence;
 +
best_offset = 100000;
 +
next_best_offset = 1000000;
 +
rgb_r = ((math.floor(px/256/256/256) % 256) - 7) * 255/247;
 +
rgb_g = ((math.floor(px/256/256) % 256) - 7) * 255/247;
 +
rgb_b = ((math.floor(px/256) % 256) - 5.5) * 255/247;
 +
lab_l, lab_a, lab_b = rgb2lab(rgb_r, rgb_g, rgb_b);
 +
hsl_h, hsl_s, hsl_l = rgb2hsl(rgb_r, rgb_g, rgb_b);
 
 
local z = 0;
+
for i=1, #color_names do
local is_done = nil;
+
checkBreak();
local value = nil;
+
test_px = color_values[i];
-- Edit box and text display
+
tst_r = (math.floor(test_px/256/256) % 256);
while not is_done do
+
tst_g = (math.floor(test_px/256) % 256);
-- Put these everywhere to make sure we don't lock up with no easy way to escape!
+
tst_b = (math.floor(test_px) % 256);
checkBreak("disallow pause");
+
lab_tst_l, lab_tst_a, lab_tst_b = rgb2lab(tst_r, tst_g, tst_b);
 +
hsl_tst_h, hsl_tst_s, hsl_tst_l = rgb2hsl(tst_r, tst_g, tst_b);
 
 
lsPrint(10, 10, z, scale, scale, 0xFFFFFFff, "Hackling Raking Setup");
+
---- Different methods to determine "distance" from the ideal colors. Change these to test different options.
 
 
-- lsEditBox needs a key to uniquely name this edit box
+
--offset = math.abs(rgb_r - tst_r) + math.abs(rgb_g - tst_g) + math.abs(rgb_b - tst_b);
--   let's just use the prompt!
+
--offset = math.max(math.max((math.abs(rgb_r - tst_r)), math.abs(rgb_g - tst_g)), math.abs(rgb_b - tst_b));
-- lsEditBox returns two different things (a state and a value)
+
offset = (rgb_r - tst_r)^2 + (rgb_g - tst_g)^2 + (rgb_b - tst_b)^2;
local y = 40;
+
--offset = math.abs(lab_l - lab_tst_l) + math.abs(lab_a - lab_tst_a) + math.abs(lab_b - lab_tst_b);
lsPrint(5, y, z, scale, scale, 0xFFFFFFff, "How much flax: ");
+
--offset = (lab_l - lab_tst_l)^2 + (lab_a - lab_tst_a)^2 + (lab_b - lab_tst_b)^2;
is_done, num_flax = lsEditBox("passes",
+
--offset = math.max(math.max((math.abs(lab_l - lab_tst_l)), math.abs(lab_a - lab_tst_a)), math.abs(lab_b - lab_tst_b));
160, y, z, 70, 30, scale, scale,
+
--offset = math.abs(hsl_h - hsl_tst_h) + math.abs(hsl_s - hsl_tst_s) + math.abs(hsl_l - hsl_tst_l);
0x000000ff, 1);
+
--offset = (hsl_h - hsl_tst_h)^2 + (hsl_s - hsl_tst_s)^2 + (hsl_l - hsl_tst_l)^2;
if not tonumber(num_flax) then
+
--offset = math.max(math.max((math.abs(hsl_h - hsl_tst_h)), math.abs(hsl_s - hsl_tst_s)), math.abs(hsl_l - hsl_tst_l));
is_done = nil;
+
if (offset < next_best_offset) then
lsPrint(10, y+18, z+10, 0.7, 0.7, 0xFF2020ff, "MUST BE A NUMBER");
+
if (offset < best_offset) then
num_flax = 1;
+
next_best_offset = best_offset;
 +
best_offset = offset;
 +
best_name = color_names[i]; -- .. "   Hex: " .. DEC_HEX(color_values[i]);
 +
else
 +
next_best_offset = offset;
 +
end
 +
confidence = ((next_best_offset - best_offset) / best_offset) * 100;
 +
end
 +
end
 +
 +
return best_name, math.floor(confidence);
 +
end
 +
 
 +
--Check pixel against target
 +
function checkColor(px)
 +
local color_name, confidence;
 +
color_name, confidence = nearestColor(px);
 +
 +
if (color_name:upper() == stop_at_color:upper()) then
 +
return true, confidence;
 +
else
 +
return false, 0;
 +
end
 +
end
 +
 
 +
-- optional message
 +
function askForPixel()
 +
local is_done = false;
 +
local have_coords = false;
 +
local color_found = false;
 +
local color_guess = "NONE";
 +
local tst_r, tst_g, tst_b, rgb_r, rgb_g, rgb_b;
 +
local confidence = 0;
 +
-- Display message until shift is held
 +
while not go_now do
 +
checkBreak();
 +
srReadScreen();
 +
y = 0;
 +
mouse_x, mouse_y = srMousePos();
 +
if not have_coords then
 +
lsPrintWrapped(0, y, 1, lsScreenX, 0.7, 0.7, 0xFFFFFFff,
 +
"Mouse over one of the Raeli Oven color pixels and press Shift.");
 +
if lsShiftHeld() then
 +
saved_x = mouse_x;
 +
saved_y = mouse_y;
 +
have_coords = true;
 +
end
 +
else
 +
lsPrintWrapped(0, y, 1, lsScreenX, 0.7, 0.7, 0xFFFFFFff,
 +
"Coords chosen, press 'Reset' to change or 'Do It' to start.");
 
end
 
end
y = y + 32;
 
improved_rake = lsCheckBox(10, y, z, 0xFFFFFFff, "Improved Rake", improved_rake);
 
 
 
if improved_rake then
+
y = y + 40;
per_rake = 30;
+
if have_coords then
 +
px = srReadPixel(saved_x, saved_y);
 +
lsPrintWrapped(0, y, 1, lsScreenX, 0.7, 0.7, 0xffffff,
 +
saved_x .. ", " .. saved_y);
 
else
 
else
per_rake = 10;
+
px = srReadPixel(mouse_x, mouse_y);
 +
lsPrintWrapped(0, y, 1, lsScreenX, 0.7, 0.7, 0xB0B0B0ff,
 +
mouse_x .. ", " .. mouse_y);
 
end
 
end
 
 
num_loops = math.floor(num_flax / per_rake);
+
y = y + 15;
 +
color_guess, confidence = nearestColor(px);
 +
lsPrintWrapped(0, y, 1, lsScreenX, 0.7, 0.7, px,
 +
"(" .. (math.floor(px/256/256/256) % 256) .. "," .. (math.floor(px/256/256) % 256) .. "," .. (math.floor(px/256) % 256) .. "," .. (px % 256) .. ") Hex: " .. DEC_HEX(math.floor((px/256) % 16777216)));
 +
 +
y = y + 20;
 +
lsPrintWrapped(0, y, 1, lsScreenX, 0.7, 0.7, px, "Best guess: " .. color_guess);
 +
y = y + 15;
 +
lsPrintWrapped(0, y, 1, lsScreenX, 0.7, 0.7, px, "Confidence: " .. confidence .. "  (higher is better)");
 +
 +
-- Testing other methods of grabbing the pixel, making sure RGBA values match
 +
-- srReadScreen();
 +
-- px2 = srReadPixelFromBuffer(mouse_x, mouse_y);
 +
-- lsPrintWrapped(0, 80, 1, lsScreenX, 0.7, 0.7, 0xB0B0B0ff,
 +
-- mouse_x .. ", " .. mouse_y .. " = " .. (math.floor(px2/256/256/256) % 256) .. "," .. (math.floor(px2/256/256) % 256) .. "," .. (math.floor(px2/256) % 256) .. "," .. (px2 % 256) );
 +
-- lsButtonText(lsScreenX - 110, lsScreenY - 90, 0, 100, px, "test1");
 +
-- lsButtonText(lsScreenX - 110, lsScreenY - 60, 0, 100, px2, "test2");
 +
 +
y = y + 20;
 +
take_screenshots = lsCheckBox(15, y, z, 0xffffffff, " Take Screenshots", take_screenshots);
 +
 +
y = y + 20;
 +
stop_at_CB = lsCheckBox(15, y, z, 0xffffffff, " Stop at Color", stop_at_CB);
 
 
y = y + 32;
+
if stop_at_CB then
 
+
y = y + 25;
if lsButtonText(170, y+32, z, 100, 0xFFFFFFff, "OK") then
+
is_done = false;
is_done = 1;
+
color_found = false;
 +
-- Edit box and text display
 +
lsPrint(10, y, z, 0.7, 0.7, 0xFFFFFFff, "Desired Color:");
 +
 +
y = y + 20;
 +
-- lsEditBox returns two different things (a state and a value)
 +
is_done, stop_at_color = lsEditBox("Desired Color:", 10, y, z, 250, 30, 0.7, 0.7, 0x000000ff, "White");
 +
--dropdown_color_cur_value = lsDropdown("ColorDropDown1", 5, y, 0, 200, dropdown_color_cur_value, color_names);
 +
 +
for i=0, #color_names do
 +
if stop_at_color and color_names[i] then
 +
if (stop_at_color:upper() == (color_names[i]):upper()) then
 +
color_found = true;
 +
end
 +
end
 +
end
 +
 +
if not color_found then
 +
lsPrint(130, y - 20, z, 0.7, 0.7, 0xFF0000ff, "No such color (Remove any spaces)");
 +
end
 +
 +
y = y + 35;
 +
lsPrint(5, y, 0, 0.6, 0.6, 0xffffffff, "Confidence Required:");
 +
is_done, confidence_threshold = lsEditBox("confthresh", 150, y, 0, 50, 30, 0.7, 0.7, 0x000000ff, confidence_threshold);
 +
confidence_threshold = tonumber(confidence_threshold);
 +
if not confidence_threshold then
 +
lsPrint(10, y+17, 10, 0.4, 0.4, 0xFF2020ff, "MUST BE A NUMBER");
 +
confidence_threshold = 10;
 +
end
 +
else
 +
is_done = true;
 +
color_found = true;
 
end
 
end
 
+
lsPrintWrapped(10, y, z+10, lsScreenX - 20, 0.7, 0.7, 0xD0D0D0ff, "This will attempt to rake " .. num_flax .. " rotten flax, requiring " .. num_loops .. " cycles.");
+
if have_coords then
 
+
if color_found then
if is_done and (not num_flax) then
+
if lsButtonText(10, lsScreenY - 30, 0, 80, 0xFFFFFFff, "Do It") then
error 'Canceled';
+
go_now = true;
 +
end
 +
end
 +
 +
if lsButtonText(100, lsScreenY - 30, 0, 80, 0xFFA500ff, "Reset") then
 +
have_coords = false;
 +
end
 
end
 
end
 
 
if lsButtonText(lsScreenX - 110, lsScreenY - 30, z, 100, 0xFFFFFFff, "End script") then
+
if lsButtonText(lsScreenX - 110, lsScreenY - 30, 0, 100, 0xFFFFFFff, "Exit") then
error "Clicked End Script button";
+
error "Canceled";
 
end
 
end
 
 
 
lsDoFrame();
 
lsDoFrame();
lsSleep(10); -- Sleep just so we don't eat up all the CPU for no reason
 
 
end
 
end
 +
-- Wait for shift to be released
 +
while lsShiftHeld() do end;
 +
xyWindowSize = srGetWindowSize();
 
end
 
end
  
  
 
function doit()
 
function doit()
promptRakeNumbers();
+
askForWindow(askText);
  askForWindow(askText);
+
askForPixel();
 
 
local step = 1;
 
local task = "";
 
local task_text = "";
 
local warn_small_font=nil;
 
local warn_large_font=nil;
 
local loop_count=1;
 
local straw = 0;
 
local tow = 0;
 
local lint = 0;
 
local clean = 0;
 
 
 
 
 
while num_loops do
+
local t0 = lsGetTimer();
 +
local px = 0;
 +
local index=0;
 +
local color_name, confidence;
 +
local do_screenshot, do_end_burn;
 +
while 1 do
 +
local y = 0;
 +
do_screenshot = false;
 
checkBreak();
 
checkBreak();
lsSleep(250);
+
lsSleep(100);
 
srReadScreen();
 
srReadScreen();
stats_black2 = nil;
+
new_px = srReadPixel(saved_x, saved_y);
stats_black3 = nil;
+
local t = (lsGetTimer() - t0) / 1000 / 60;
+
t = math.floor(t*10 + 0.5)/10;
stats_black = srFindImage("AllStats-Black.png");
+
local t_string = t;
if not stats_black then
+
if not (new_px == px) then
stats_black2 = srFindImage("AllStats-Black2.png");
+
index = index+1;
if not stats_black2 then
+
px = new_px;
stats_black3 = srFindImage("AllStats-Black3.png");
+
color_name, confidence = nearestColor(px);
if stats_black3 then
+
if take_screenshots then
warn_large_font = true;
+
do_screenshot = true;
 +
end
 +
 +
if stop_at_CB then
 +
if (color_name:upper() == stop_at_color:upper()) then
 +
if confidence > confidence_threshold then
 +
do_end_burn = true;
 +
else
 +
for i = 1, 3 do
 +
lsPlaySound("Clank.wav");
 +
lsSleep(50);
 +
end
 +
end
 +
else
 +
lsPlaySound("Clank.wav");
 
end
 
end
 
else
 
else
warn_small_font = true;
+
lsPlaySound("Clank.wav");
 
end
 
end
 
end
 
end
 
 
local warning="";
+
if warn_small_font then
+
y = y + 5;
warning = "Your font size appears to be smaller than the default, many macros here will not work correctly.";
+
lsPrintWrapped(5, y, 1, lsScreenX - 10, 0.7, 0.7, 0xFFFFFFff,
elseif warn_large_font then
+
"Screen: " .. index .. "  Timer: " .. t_string);
warning = "Your font size appears to be larger than the default, many macros here will not work correctly.";
+
y = y + 15;
 +
lsPrintWrapped(5, y, 1, lsScreenX - 10, 0.7, 0.7, 0xFFFFFFff,
 +
"Color: " .. color_name .. " Confidence: " .. confidence);
 +
 +
y = y + 30;
 +
lsPrintWrapped(5, y, 1, lsScreenX - 10, 0.7, 0.7, 0xFFFFFFff,
 +
"(" .. (math.floor(px/256/256/256) % 256) .. "," .. (math.floor(px/256/256) % 256) .. "," .. (math.floor(px/256) % 256) .. "," .. (px % 256) .. ")  Hex: " .. DEC_HEX(math.floor((new_px/256) % 16777216)));
 +
 +
if lsButtonText(lsScreenX - 110, lsScreenY - 30, 0, 100, 0xFFFFFFff, "Exit") then
 +
error "Canceled";
 +
end
 +
lsDoFrame();
 +
srReadScreen();
 +
if do_screenshot then
 +
srSaveLastReadScreen("screen_" .. index .. "_" .. t_string .. ".png");
 +
end
 +
 +
if do_end_burn then
 +
clickAllText("Interrupt");
 +
lsPlaySound("Complete.wav");
 +
error ("Stopped burn at: " .. stop_at_color .. " Confidence: " .. confidence);
 
end
 
end
 +
end
 +
end
 +
</pre>
 +
{{Collapse bottom}}
 +
 +
{{Collapse top|title=Food Timer (IN TESTING v1)}}
 +
<pre>
 +
-- Food stat timer, made by Selune. Version 1.
 +
 +
loadfile("luaScripts/screen_reader_common.inc")();
 +
loadfile("luaScripts/ui_utils.inc")();
  
if step == 1 then
+
per_click_delay = 10;
task = "Separate Rotten Flax";
+
log_lines = {};
task_text = "Separate Straw";
+
num_log_lines = 10;
elseif step == 2 then
+
food_name = "Blocker";
task = "Continue processing Rotten";
+
function log(msg)
task_text = "Separate Tow";
+
lsPrintln(msg);
elseif step == 3 then
+
if #log_lines == num_log_lines then
task = "Continue processing";
+
for i=1,num_log_lines-1 do
task_text = "Refine the Lint";
+
log_lines[i] = log_lines[i+1];
elseif step == 4 then
 
task = "Clean the";
 
task_text = "Clean the Rake";
 
 
end
 
end
 +
log_lines[num_log_lines] = msg;
 +
else
 +
log_lines[#log_lines+1] = msg;
 +
end
 +
end
 +
 +
local last_time = 0;
 +
function timedLog(new_time)
 +
local timeDiff;
 +
 +
timeDiff = new_time - last_time;
 +
last_time = new_time;
 +
 +
log(food_name .. " -- Duration: " .. math.floor(timeDiff / 1000 / 60) .. ":" .. math.mod(timeDiff / 1000, 60));
 +
end
 +
 +
function askForImage()
 +
haveCoords = false;
 +
go_now = false;
 +
while not go_now do
 +
checkBreak();
 +
srReadScreen();
 +
mouse_x, mouse_y = srMousePos();
 +
local y = 10;
 +
local x = 40;
 
 
if not stats_black and not stats_black2 and not stats_black3 then
+
if not have_coords then
sleepWithStatus(1200, "Next Step: " .. step .. "/4 - " .. task_text .. "\n----------------------------------------------\n1) Straw Removed: " .. straw .."/" .. num_loops*per_rake .. "\n2) Tow Seperated: " .. tow .. "/" .. num_loops*per_rake .. "\n3) Lint Refined: " .. lint .. "/" .. num_loops*per_rake .. "\n4) Cleanings: " .. clean .. "/" .. num_loops .. "\n----------------------------------------------\nFlax Processed: " .. (loop_count-1)*per_rake .. "\nFlax Remaining: " .. num_flax - ((loop_count-1)*per_rake) .. "\n" .. warning);
+
lsPrintWrapped(x, y, 1, lsScreenX - x - 10, 0.7, 0.7, 0xFFFFFFff,
elseif loop_count >= num_loops then
+
"Put your mouse in the top left of the Strength stat NUMBER. You should see all stat values in the preview. It doesn't have to be perfect!");
num_loops = nil;
+
 +
srMakeImage("CUSTOM", mouse_x, mouse_y, 10, 100);
 +
if lsShiftHeld() then
 +
saved_x = mouse_x;
 +
saved_y = mouse_y;
 +
have_coords = true;
 +
end
 
else
 
else
+
lsPrintWrapped(x, y, 1, lsScreenX - x - 10, 0.7, 0.7, 0xFFFFFFff,
srReadScreen();
+
"Coords chosen, press 'Reset' to change or 'Do It' to start.");
lsSleep(50);
+
srMakeImage("CUSTOM", saved_x, saved_y, 10, 100);
clickAllText("This Is");
+
end
lsSleep(200);
 
 
 
srReadScreen();
+
if have_coords then
lsSleep(50);
+
if lsButtonText(10, lsScreenY - 30, 0, 80, 0xFFFFFFff, "Do It") then
clickAllText(task);
+
go_now = true;
lsSleep(200);
 
if step == 1 then
 
straw = straw + per_rake;
 
elseif step == 2 then
 
tow = tow + per_rake;
 
elseif step == 3 then
 
lint = lint + per_rake;
 
elseif
 
step == 4 then
 
clean = clean + 1;
 
step = 0;
 
loop_count= loop_count +1;
 
 
end
 
end
step = step + 1;
 
sleepWithStatus(300, "Refreshing screen");
 
 
 
srReadScreen();
+
if lsButtonText(100, lsScreenY - 30, 0, 80, 0xFFA500ff, "Reset") then
lsSleep(50);
+
have_coords = false;
clickAllText("This Is");
+
end
lsSleep(200);
+
end
 +
 +
if lsButtonText(lsScreenX - 100, lsScreenY - 30, 0, 80, 0xFFFFFFff, "Exit") then
 +
error "Canceled";
 
end
 
end
 
+
 +
srShowImageDebug("CUSTOM", 8, 8, 1, 3);
 +
lsDoFrame();
 +
end
 
end
 
end
if num_loops == nil then
 
sleepWithStatus(5000, "ALL DONE!\n----------------------------------------------\n1) Straw Removed: " .. straw .."/" .. clean*10 .. "\n2) Tow Seperated: " .. tow .. "/" .. clean*10 .. "\n3) Lint Refined: " .. lint .. "/" .. clean*10 .. "\n4) Cleanings: " .. clean .. "/" .. clean .. "\n----------------------------------------------\nFlax Processed: " .. (loop_count-1)*10 .. "\nFlax Remaining: " .. num_flax - ((loop_count-1)*10));
 
  
lsPlaySound("Complete.wav");
+
function doit()
 +
askForWindow("Food Timer - Records how long a particular meal lasts, down to the half-second. Works even with aqueduct or other already-running food buffs (So eat blocker first!) Made by Selune!");
 +
askForImage();
 +
srMakeImage("CUR_STATS", saved_x, saved_y, 10, 100);
 +
 +
for i=1, 20 do
 +
log("...");
 +
end
 +
 +
local t0 = lsGetTimer();
 +
local new_time;
 +
while 1 do
 +
local i = 0;
 +
local y = 5;
 +
local x = 40;
 +
local is_done = false;
 +
new_time = lsGetTimer();
 +
checkBreak();
 +
lsSleep(100);
 +
srReadScreen();
 +
 +
lsPrintWrapped(x, y, 1, lsScreenX - x - 10, 1, 1, 0xFFFFFFff,
 +
"Now recording, eat up!");
 +
 +
y = y + 25;
 +
lsPrintWrapped(x, y, 1, lsScreenX - x - 10, 1, 1, 0xFF2020ff,
 +
"Remember to block first!");
 +
 +
y = y + 30;
 +
lsPrintWrapped(x, y, 1, lsScreenX - x - 10, 0.7, 0.7, 0xC0C0C0ff,
 +
"Name (for log):");
 +
 +
y = y + 20;
 +
is_done, food_name = lsEditBox("Food Name:", x, y, z, 250, 30, 0.7, 0.7, 0x000000ff, food_name);
 +
 +
if not srFindImageInRange("CUR_STATS", saved_x, saved_y, 10, 100) then
 +
lsSleep(500);
 +
srReadScreen();
 +
srMakeImage("CUR_STATS", saved_x, saved_y, 10, 100);
 +
for i = 1, 3 do
 +
lsPlaySound("Clank.wav");
 +
lsSleep(100);
 +
end
 +
timedLog(new_time - t0);
 +
end
 +
 +
y = y + 30;
 +
if #log_lines then
 +
for i=1, #log_lines do
 +
lsPrint(x + 10, y, 1, 0.7, 0.7, 0x808080ff, log_lines[i]);
 +
y = y + 15;
 +
end
 +
end
 +
 +
if lsButtonText(lsScreenX - 110, lsScreenY - 30, 0, 100, 0xFFFFFFff, "Exit") then
 +
error "Canceled";
 +
end
 +
 +
srShowImageDebug("CUR_STATS", 8, 8, 1, 3);
 +
lsDoFrame();
 
end
 
end
 
end
 
end
 
</pre>
 
</pre>
 
{{Collapse bottom}}
 
{{Collapse bottom}}

Latest revision as of 21:04, 9 February 2013

Selune's Macros have been updated to the TaleScripts repository. Please leave any ideas for improvements or new macros here.