Results 1 to 6 of 6

Thread: Boolean function and procedure help?

  1. #1
    Join Date
    Nov 2015
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default Boolean function and procedure help?

    So ive been working on this woodcutting script for the last couple days now, and im not really sure how to explain it so ill give you guys the example im working with. Im trying to chop trees and have a function tell me when the tree has been chopped or not using boolean. I have cutting the willows part nailed down now i need it to wait until its done cutting the first tree before it moves on to the second. I was gonna use pixel shifts btw to tell if the willow is cut down or not. I have rough draft of the script right now and its pretty sloppy i know but i just wanna nail down the important parts first. And also not sure if i posted the script right?



    Willow_cutter.simba
    Last edited by krogh424; 12-11-2015 at 05:25 AM.

  2. #2
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Simba tags would be more useful than a download
    Simba Code:
    1. program woodCutter;
    2. {$DEFINE SMART}              // Always have this to load smart
    3. {$I SRL-6/SRL.simba}         // To load the SRL include files
    4. {$I SPS/lib/SPS-RS3.Simba}   // To load the SPS include files
    5. {$loadlib AND_TPA}
    6.  
    7. procedure declarePlayers();
    8. begin
    9.   setLength(players, 1);
    10.   with players[0] do
    11.   begin
    12.     loginName := '';
    13.     password := '';
    14.     isActive := true;
    15.     isMember := false;
    16.   end
    17.   currentPlayer := 0;
    18. end;
    19.  
    20. ////////////////*************SCRIPT*****************\\\\\\\\\\\\\\\\\\\\\\\\\\\
    21.  
    22.   //RunToTrees
    23. procedure runToTrees();
    24. var
    25.   pathToTrees: TPointArray;
    26. begin
    27.      if not isLoggedIn() then
    28.     exit;
    29.  
    30.   pathToTrees := [Point(49, 35), Point(54, 45), Point(68, 61), Point(73, 75), Point(79, 96), Point(85, 114), Point(93, 149), Point(95, 172), Point(95, 189), Point(100, 216), Point(104, 242),Point(125, 252)];
    31.  
    32.   if SPS.walkPath(pathToTrees) then
    33.     minimap.waitPlayerMoving()
    34.   else
    35.     writeLn('We failed to walk to the trees');
    36. end;
    37.  
    38. //changeCompass
    39. procedure changeCompass();
    40. begin
    41.     //minimap.setAngle(MM_DIRECTION_SOUTH);
    42. end;
    43.  
    44. //chopTrees
    45. function chopTrees(): boolean;
    46. var
    47.   x, y, i, r : integer;
    48.   TPA: TPointArray;
    49.   TPA_Brown: TPointArray;
    50.   TPA_Green: TPointArray;
    51.   TPA_Willow: TPointArray;
    52.   ATPA: T2DPointArray;
    53.   treeTimer: TTimeMarker;
    54. begin
    55.   if not isLoggedIn() then
    56.     exit;
    57.  
    58.    // treetimer.start();
    59.  
    60.   repeat
    61.   if (tabBackpack.isFull()) then
    62.       Break;
    63.     wait(randomRange(500, 1500));
    64.     //spiral tolerance starts x,y first and then spirals out
    65.       //willows
    66.       findColorsSpiralTolerance(x, y, TPA_Willow, 2703947, mainScreen.getBounds(), 3, colorSetting(2, 0.57, 2.21));
    67.  
    68.       if not isLoggedIn() then
    69.     exit;
    70.  
    71.     if (Length(TPA_Willow) < 1) then
    72.     exit;
    73.  
    74.     //FilterTPADistTPA(TPA_Brown,1,50,TPA_Green);
    75.  
    76.     //ATPA := TPA_Brown.cluster(5);
    77.     ATPA := TPA_Willow.cluster(5);
    78.     ATPA.filterBetween(0, 10);
    79.     ATPA.sortFromMidPoint(mainscreen.playerPoint);
    80.     smartImage.debugATPA(ATPA);
    81.  
    82.     for i := 0 to high(ATPA) do
    83.     begin
    84.    { if random(9) = 4 then
    85.       smallRandomMouse(80 + random(100));
    86.     if random(20) = 5 then
    87.       sleepAndMoveMouse(randomRange(250, 750));
    88.     }
    89.     mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
    90.     inc(r);
    91.       if isMouseOverText(['hop','down','illow'], 300)  then
    92.  
    93.        begin
    94.           treetimer.start();
    95.         if random(30) = 1 then
    96.         begin
    97.           wait(randomRange(500, 1000));
    98.           fastClick(MOUSE_RIGHT);
    99.           chooseOption.select(['hop','down','illow']);
    100.           smartImage.clear();
    101.           break;
    102.         end;
    103.        // else
    104.        //  if isMouseOverText(['hop','down','oak'], 100)  then
    105.          //    if random(30) = 1 then
    106.        // begin
    107.        //   wait(randomRange(1560, 2600));
    108.        //   fastClick(MOUSE_RIGHT);
    109.        //   chooseOption.select(['hop','down','oak']);
    110.       //    tabBackpack.waitForShift(10000);
    111.        ///   smartImage.clear();
    112.        //   break;
    113.       //  end
    114.  
    115.         //else if treeTimer.getTime() >= 6000 then
    116.           //TerminateScript;
    117.  
    118.         if random(100) = 4 then
    119.        // begin
    120.        //   antiban();
    121.        // end;
    122.         if random(200) = 4 then
    123.         smallRandomMouse(10 + random(10));
    124.         //
    125.         fastClick(MOUSE_LEFT);
    126.         //
    127.         if random(200) = 4 then
    128.         fastClick(MOUSE_LEFT);
    129.  
    130.         wait(1000 + random(500));
    131.  
    132.         if random(50) = 5 then
    133.         sleepAndMoveMouse(randomRange(1000, 1400));
    134.         //
    135.         smartImage.clear();
    136.         break;
    137.         end;
    138.  
    139.   end;
    140.     //tabBackpack.waitForShift(4000);
    141.    // claimSpinTicket();
    142.       // if (tabBackpack.isItemInSlot(28)) then
    143.       // begin
    144.         //   wait(100)
    145.        //chooseOption.select(['rop','']);
    146.  
    147.       // end;
    148.  
    149.   until (not isLoggedIn()) or (treeTimer.getTime() > 20000);
    150.  
    151.   minimap.setAngle(MM_DIRECTION_NORTH);
    152.   mainScreen.setAngle(MS_ANGLE_HIGH);
    153. end;
    154.  
    155.  
    156.  //packIsFull
    157. procedure  packIsFull();
    158. var
    159.     dropTimer: TTimeMarker;
    160. begin
    161.      if tabBackpack.isFull() then
    162.       writeln('The backpack is full!');
    163.                tabBackpack.dropItems();
    164.                minimap.clickCompass(true);
    165.                mainScreen.setAngle(MS_ANGLE_HIGH);
    166.  
    167.                //minimap.mouseOffCompass();
    168.                smartImage.clear();
    169. end;
    170.  
    171. //isStillChopping
    172. function isStillChopping(): boolean;
    173. var
    174.   pxShift:integer;
    175. begin
    176.   if (not (isLoggedIn())) then
    177.    exit;
    178.  
    179.   if tabBackpack.isFull() then
    180.    exit(false);
    181.  
    182.   smartImage.drawBox(mainScreen.playerBox, false, clRed);
    183.   pxShift := getPixelShiftAverage(mainScreen.playerBox, 50, 500);
    184.   result := (pxShift > 150);
    185.  
    186.   //writeDebug('Still chopping? ' + lowercase(toStr(result)) + ', with an average pixel shift of ' + toStr(pxShift));
    187.  
    188.    end;
    189.  
    190.    //waitWhileChopping
    191.    procedure waitWhileChopping();
    192. begin
    193.   if (not isLoggedIn()) then
    194.    exit;
    195.  
    196.   while isStillChopping() do
    197.    begin
    198.     // smartImage.debugDtm(oakLogsDtm, tabBackpack.getBounds(), clRed);
    199.      wait(randomRange(800,1500));
    200.      writeln('*****we are still chopping******');
    201.      //antiPattern();
    202.    end;
    203. end;
    204.  
    205. // main loop
    206. begin
    207.   clearDebug();
    208.   smartEnableDrawing := true;
    209.   setupSRL();
    210.   declarePlayers();
    211.  
    212.   SPS.setup('Clay_miner01',RUNESCAPE_OTHER);
    213.  
    214.   if not isLoggedIn() then
    215.   begin
    216.     players[currentPlayer].login();
    217.     exitTreasure();
    218.     minimap.setAngle(MM_DIRECTION_NORTH);
    219.     mainScreen.setAngle(MS_ANGLE_HIGH);
    220.   end;
    221.  
    222.  // packIsFull();
    223.  repeat
    224.  
    225.   repeat
    226.      if chopTrees() then
    227.     waitWhileChopping();
    228.  
    229.   until tabBackPack.isFull
    230.  
    231.  if tabBackPack.isFull() then
    232.     begin
    233.   packIsFull();
    234.        end;
    235.  
    236.   until false;
    237.  
    238. end.

    Plus it's hard to read through a messy script. You should clean it up a bit.

    Personally I check for xp or inventory shift in my wc scripts. You can use pixel shift if your character will always be visible.
    Last edited by Citrus; 12-11-2015 at 06:52 AM.

  3. #3
    Join Date
    Nov 2015
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Yea i was considering using a shift inventory, so i was using KeepBotting's iOak as a reference to see how his works... i never thought of using xp as a way of checking tho. Could you elaborate on that im curious now? maybe some sudo?

  4. #4
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    I'll assume you meant pseudo, meaning "false" and not sudo, meaning "substitute (or super) user do"
    but anyway here's a function you could use
    Simba Code:
    function checkXP(time: integer): boolean;
    var
      xp, ixp: integer;
      cd: TCountDown;
    begin
      result := false;
      ixp := chatBox.getXPBar();
      cd.setTime(time);
      while (not cd.isFinished()) do
      begin
        xp := chatBox.getXPBar();
        if (xp <> ixp) then exit(true);
        wait(20 + random(20));
      end;
    end;
    Last edited by Citrus; 12-11-2015 at 09:49 AM.

  5. #5
    Join Date
    Nov 2015
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    sorry i had a brain fart their... its kinda late maybe but yea its pseudo code. not sure i get this line of code tho?



    Simba Code:
    if (xp <> ixp) then exit(true);

    **wats up with the wait times?

  6. #6
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by krogh424 View Post
    sorry i had a brain fart their... its kinda late maybe but yea its pseudo code. not sure i get this line of code tho?



    Simba Code:
    if (xp <> ixp) then exit(true);

    **wats up with the wait times?
    http://blog.wizzup.org/blog/lape#inequality

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •