Simba Code:
program WoodCutter;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
procedure teleportToFalador(); // function to teleport to falador
var
p: TPoint;
begin
if not isLoggedIn() then
exit();
writeln('Teleporting back to falador');
repeat
lodestoneScreen.teleportTo(LOCATION_FALADOR);
wait(randomRange(16000,17500));
until (minimap.findSymbol(p, MM_SYMBOL_ALTAR, minimap.getBounds())); //keep teleporting until we are actually there.
end;
procedure walkToTrees() // Procedure to get to the trees, I should use SPS maps but couldn't get it working
begin // this is only temporary
writeln('walking to trees'); // will be changed to use SPS map ASAP
mouse(750,50,MOUSE_MOVE);
wait(100);
fastClick(MOUSE_LEFT);
wait(500);
minimap.waitPlayerMoving();
mouse(720,50,MOUSE_MOVE);
wait(100);
fastClick(MOUSE_LEFT);
wait(500);
minimap.waitPlayerMoving();
writeln('Arrived at the trees');
end;
procedure lookForTrees() //looks around randomly, hoping to find a tree
begin
minimap.setAngle(randomrange(0,360));
wait(500);
end;
procedure findTrees() // This is the actual 'Tree finding' procedure using findColorSpiral
var
x, y, i, counter: integer;
TPA: TPointArray;
ATPA : T2DPointArray;
begin
if(not isLoggedIn()) then
exit();
writeln('Looking for trees');
repeat // Note: The following code is so my player doesn't pick the tree in the upper left corner but
// tries to find a tree close to him first.
findColorsSpiralTolerance(x, y, TPA, 990749, 150, 100, 350, 300, 5); //search for trees close to the player first
if(length(TPA) < 1) then // if we didn't find trees closeby,
findColorsSpiralTolerance(x, y, TPA, 990749, 0, 0, 500, 300, 5); //search for trees on the entire screen.
if(length(TPA) < 1) then
lookForTrees(); // If we don't find trees on the screen whatsoever,
// look around and try to spot some trees
ATPA := TPA.toATPA(30,30);
ATPA.filterBetween(0,40);
ATPA.sortFromFirstPoint(mainScreen.playerPoint);
smartImage.debugATPA(ATPA);
if(length(ATPA) < 1) then //If we found the color, but not enough pixels for a tree, look around again.
lookForTrees();
for i:= 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]),MOUSE_MOVE);
if isMouseOverText(['Chop down Evergreen'], 500) then //check whether it is actually a tree and not just large green
begin //object that happens to have the exact same color
writeln('Found some trees!');
fastClick(MOUSE_LEFT);
wait(100);
minimap.waitPlayerMoving(1000);
tabBackpack.waitForShift(5000);
smartImage.clear;
break;
end
else
begin
writeln('no trees found, looking around.'); //if it wasn't a tree, look around for more trees.
lookForTrees();
end;
end;
until tabBackpack.isFull(); //keep chopping untill the backpack is full
end;
procedure goToBank()
var // goes to bank, again no SPS map because I couldn' get it working yet
x, y: integer; // deposits the logs in the deposit box at Port Sarim
p: TPoint;
TPA: TPointArray;
begin
writeln('we should go to a bank');
repeat
minimap.clickCompass();
lodestoneScreen.teleportTo(LOCATION_PORT_SARIM);
wait(randomRange(16000,17500));
until minimap.findSymbol(p,MM_SYMBOL_SHOP_FISHING,minimap.getBounds());
mouse(760,60,MOUSE_MOVE);
wait(100);
fastClick(MOUSE_LEFT);
wait(200);
minimap.waitPlayerMoving();
wait(500);
mouse(775,69,MOUSE_MOVE);
wait(100);
fastClick(MOUSE_LEFT);
wait(200);
minimap.waitPlayerMoving();
wait(2000);
findColorTolerance(x, y, 5467010,100,0,500,300,6); // looks for the deposit box colors
mouse(x, y, MOUSE_MOVE);
wait(100);
fastClick(MOUSE_LEFT);
wait(2000);
mouseBox(intToBox(320,290,340,300),MOUSE_MOVE);
wait(100);
fastClick(MOUSE_LEFT);
end;
// main loop
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
if not isLoggedIn() then // If player isn't logged in then
begin
writeln('Not logged in yet, terminating script');
exit();
end;
if isLoggedIn() then
begin
writeln('We are logged in!');
exitTreasure();
minimap.clickCompass();
mainScreen.setAngle(MS_ANGLE_HIGH);
end;
if(tabBackpack.count > 2) then
begin
write('there are ');
write(tabBackpack.count);
writeln(' items in the backpack, we need to visit the bank first');
goToBank();
end;
repeat //main loop
teleportToFalador();
walkToTrees();
findTrees();
goToBank();
until false;
end.