Results 1 to 4 of 4

Thread: Need help improving my script

  1. #1
    Join Date
    Dec 2014
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    13 Post(s)

    Default Need help improving my script

    So i wanted to make a flax spinner script (didn't know there was one already). So i looked at the tutorials and used my basic coding knowledge to make it. Guess what, it works. But i want more: right now it works but it acts kinda like a bot and stands still sometimes. I want to make it much more smooth. When everything is much smoother i want to make it even better so i can publish it and return to this community. Things i'd love to add but i have no idea to start: add player manager, add regular breaks, add an amount that has to be spun and add a proggy with the amount that has been spun, amount of xp and the amount of profit. I'll post my code here ( it is quite messy btw don't mind my epic until statement: until 0=2).
    Simba Code:
    program Bowstringmaker;
    {$DEFINE SMART}
    {$I SRL-6/SRL.simba}

    procedure Findingbank();
    var
    x,y: integer;
    Banksymbol: TPoint;
    begin
     wait(randomRange(500,750));
     minimap.findSymbol(Banksymbol, MM_SYMBOL_BANK, minimap.getBounds());
     mouse(Banksymbol, MOUSE_LEFT);
     wait(RandomRange(4750,5750));
    if mainscreen.findObject(x, y, 10792122,6, ['ank'], MOUSE_RIGHT) then

    begin
        writeLn('Found Banker'); // If findObject returns true, this will print
        chooseOption.select(['ank']);
      end;
      exit();
    end;


    procedure Banking();

    begin
      wait(randomRange(1000, 1500));
      bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
      wait(randomRange(1000, 1500));
      bankScreen.clickButton(BANK_BUTTON_PRESET_2);
      bankScreen.close();

    end;

    procedure GoingDownStairs();
    var
        x,y,Point1DTM: integer;
          begin
    Point1DTM := DTMFromString('mrAAAAHic42BgYNjExcBwDIi3QOnFQLwCiP25GRjWAGkjRgYGJyB2AGIDILYCYj0gjgdifyCelB/CsGXrRoYsfxOGimgbhhx/U4a2VE8G56TTDDt3b2aQBNqBDzMSwDAAAFteE4o=');



        if findDTM(Point1DTM, x, y, mainscreen.getBounds()) then
        begin
        wait(250);
        mouse(x,y,3,3, MOUSE_MOVE);
         if isMouseOverText(['aircase']) then
        begin
        writeln('gelukt');

        minimap.waitPlayerMoving();
        mouse(x,y,1,1, MOUSE_LEFT);
        minimap.waitPlayerMoving();
        wait(randomRange(1000,1500));

        end


         end
       end
    procedure GoingToSpinningWheel();
    var
        SpinningWheelsymbol: TPoint;
    begin
    minimap.waitPlayerMoving();
    wait(randomRange(500,750));
       minimap.findSymbol(SpinningWheelsymbol, MM_SYMBOL_WHEEL, minimap.getBounds());
       mouse(SpinningWheelsymbol, MOUSE_LEFT);
       wait(RandomRange(500,750));
       minimap.waitPlayerMoving();
       wait(RandomRange(500,750));
    end;


    procedure Spinning();
    var x,y,WheelDTM: integer;
    begin
        //if mainscreen.findObject(x, y, 5470606,9, colorSetting(2, 0.13, 0.52), mainscreen.playerPoint, 20, 10, 1, ['pinning'], MOUSE_RIGHT) then
          // begin
        WheelDTM := DTMFromString('mggAAAHicY2NgYNjIzMCwAYg3AfEJIF4MxCYsDAzPGRkY3gPxYyD+CcRfgHgXELekuDOsac1haExyYZg1ezbDuVOHGdwyzjBIAs3ChhlxYAgAAES/E2Y=');
        if findDTM(WheelDTM, x, y, mainscreen.getBounds()) then
        begin
        mouse(x,y,3,3, MOUSE_MOVE);

        if isMouseOverText(['pinning']) then
        begin
        mouse(x,y,1,1, MOUSE_RIGHT);
        //wait(randomRange(250,750));
        chooseOption.select(['pin']);
        productionscreen.isOpen(randomRange(750, 1500));
        minimap.waitPlayerMoving();
        wait(randomRange(250,500));
        productionscreen.clickStart(true);
        wait(randomRange(52250, 54000));
        end
        end
           //end

    end;

    procedure GoingUpstairs();
    var
        x,y,StairDTM: integer;


    begin

        StairDTM := DTMFromString('mbQAAAHicY2VgYOBgZmDgAuIXTAwMGkBaFIjNgGwpIHYGYg8gjgTiDZvWMNTG2jO0pXgydGf6MbSlejJIAvWjY0YsGAwAcboJ2w==');
        if findDTM(StairDTM, x, y, mainscreen.getBounds()) then
        begin
        mouse(x,y,3,3, MOUSE_MOVE);
        minimap.waitPlayerMoving();
        if isMouseOverText(['aircase']) then
        begin
        mouse(x,y,1,1, MOUSE_RIGHT);

        chooseOption.select(['up']);
        minimap.waitPlayerMoving()

        end
        end


    end;

    begin
      clearDebug();
      setupSRL();
      wait(500);
      minimap.clickCompass();
      wait(500);
      mainScreen.setAngle(MS_ANGLE_HIGH);
      repeat
      Findingbank();
      Banking();
      GoingDownstairs();
      GoingToSpinningWheel();
      Spinning();
      GoingUpstairs();
      until
       0=2;
    end.

    The only thing that you have to set up is that quick inventory 2 has to contain all flax. You have to start in lumbridge castle in the bank. Some help would be really nice and sorry for the long post :/. If i missed something feel free to ask away

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

    Default

    Here, I fixed up what you had. It still has a lot of room for improvement, but that's for you to do

    Simba Code:
    1. program Bowstringmaker;
    2. {$DEFINE SMART}
    3. {$I SRL-6/SRL.simba}
    4.  
    5. procedure Findingbank();
    6. var
    7.   x,y: integer;
    8.   Banksymbol: TPoint;
    9. begin
    10.   wait(randomRange(500,750));
    11.   if minimap.findSymbol(Banksymbol, MM_SYMBOL_BANK, minimap.getBounds()) then
    12.   begin
    13.     mouse(Banksymbol, MOUSE_LEFT);
    14.     //wait(RandomRange(4750,5750));
    15.     minimap.waitPlayerMoving();
    16.     if mainscreen.findObject(x, y, 10792122,6, ['ank'], MOUSE_RIGHT) then
    17.     begin
    18.       writeLn('Found Banker'); // If findObject returns true, this will print
    19.       chooseOption.select(['ank']);
    20.     end;
    21.   end;
    22. end;
    23.  
    24. procedure Banking();
    25.  
    26. begin
    27.   //wait(randomRange(1000, 1500)); //not needed
    28.   if bankScreen.isOpen(2000) then
    29.   begin
    30.     //bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY); //redundant
    31.     //wait(randomRange(1000, 1500)); //not needed
    32.     bankScreen.clickButton(BANK_BUTTON_PRESET_2);
    33.     tabBackPack.waitWhileLocked(1000);
    34.     //bankScreen.close(); //redundant
    35.   end;
    36. end;
    37.  
    38. procedure GoingDownStairs();
    39. var
    40.   x, y, Point1DTM: integer;
    41. begin
    42.   Point1DTM := DTMFromString('mrAAAAHic42BgYNjExcBwDIi3QOnFQLwCiP25GRjWAGkjRgYGJyB2AGIDILYCYj0gjgdifyCelB/CsGXrRoYsfxOGimgbhhx/U4a2VE8G56TTDDt3b2aQBNqBDzMSwDAAAFteE4o=');
    43.   if findDTM(Point1DTM, x, y, mainscreen.getBounds()) then
    44.   begin
    45.     wait(250);
    46.     mouse(x,y,3,3, MOUSE_MOVE);
    47.     if isMouseOverText(['aircase']) then
    48.     begin
    49.       writeln('gelukt');
    50.       //minimap.waitPlayerMoving(); //doesn't do anything
    51.       mouse(x,y,1,1, MOUSE_LEFT);
    52.       minimap.waitPlayerMoving();
    53.       wait(randomRange(1000,1500));
    54.     end;
    55.   end;
    56. end;
    57.  
    58. procedure GoingToSpinningWheel();
    59. var
    60.   SpinningWheelsymbol: TPoint;
    61. begin
    62.   //minimap.waitPlayerMoving();
    63.   //wait(randomRange(500,750));
    64.   if minimap.findSymbol(SpinningWheelsymbol, MM_SYMBOL_WHEEL, minimap.getBounds()) then
    65.   begin
    66.     mouse(SpinningWheelsymbol, MOUSE_LEFT);
    67.     wait(RandomRange(500,750));
    68.     minimap.waitPlayerMoving();
    69.     //wait(RandomRange(500,750));
    70.   end;
    71. end;
    72.  
    73. procedure Spinning();
    74. var
    75.   x, y, WheelDTM: integer;
    76. begin
    77.   //if mainscreen.findObject(x, y, 5470606,9, colorSetting(2, 0.13, 0.52), mainscreen.playerPoint, 20, 10, 1, ['pinning'], MOUSE_RIGHT) then
    78.   // begin
    79.   WheelDTM := DTMFromString('mggAAAHicY2NgYNjIzMCwAYg3AfEJIF4MxCYsDAzPGRkY3gPxYyD+CcRfgHgXELekuDOsac1haExyYZg1ezbDuVOHGdwyzjBIAs3ChhlxYAgAAES/E2Y=');
    80.   if findDTM(WheelDTM, x, y, mainscreen.getBounds()) then
    81.   begin
    82.     mouse(x,y,3,3, MOUSE_MOVE);
    83.     if isMouseOverText(['pinning']) then
    84.     begin
    85.       mouse(x,y,1,1, MOUSE_RIGHT);
    86.       //wait(randomRange(250,750));
    87.       if chooseOption.select(['pin']) then
    88.       begin
    89.         if productionscreen.isOpen(randomRange(750, 1500)) then
    90.         begin
    91.         //minimap.waitPlayerMoving(); //pointless
    92.         //wait(randomRange(250,500));
    93.         if productionscreen.clickStart(true) then
    94.           tabBackPack.waitSlotPixelChange(28, 55000);
    95.         //wait(randomRange(52250, 54000)); //bad
    96.         end;
    97.       end;
    98.     end;
    99.   end;
    100.   //end
    101. end;
    102.  
    103. procedure GoingUpstairs();
    104. var
    105.   x,y,StairDTM: integer;
    106. begin
    107.   StairDTM := DTMFromString('mbQAAAHicY2VgYOBgZmDgAuIXTAwMGkBaFIjNgGwpIHYGYg8gjgTiDZvWMNTG2jO0pXgydGf6MbSlejJIAvWjY0YsGAwAcboJ2w==');
    108.   if findDTM(StairDTM, x, y, mainscreen.getBounds()) then
    109.   begin
    110.     mouse(x,y,3,3, MOUSE_MOVE);
    111.     //minimap.waitPlayerMoving();
    112.     if isMouseOverText(['aircase']) then
    113.     begin
    114.       mouse(x,y,1,1, MOUSE_RIGHT);
    115.       chooseOption.select(['up']);
    116.       minimap.waitPlayerMoving();
    117.     end;
    118.   end;
    119. end;
    120.  
    121. begin
    122.   clearDebug();
    123.   setupSRL();
    124.   wait(500);
    125.   minimap.clickCompass();
    126.   wait(500);
    127.   mainScreen.setAngle(MS_ANGLE_HIGH);
    128.   repeat
    129.     Findingbank();
    130.     Banking();
    131.     GoingDownstairs();
    132.     GoingToSpinningWheel();
    133.     Spinning();
    134.     GoingUpstairs();
    135.   until (not isLoggedIn()); //better than 0=2
    136. end.

    I'ts really important to get your indentation correct if you're going to be asking for help.
    There is a lot of pointless and redundant code, which makes me think you're writing stuff without understand what it does.

    Go through what I've changed and then post any questions you might have.

  3. #3
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Congratulations on a first working script! Have you checked out these threads?

    Player Form Tutorial
    Progress Paint Tutorial

    You can create a "flax-to-spin" feature by creating a global integer variable that tracks spun flax.

    Simba Code:
    //Global variables and constants

    const
      FLAX_TO_SPIN = 2000;

    var
      spunFlax: integer;

    {...script content...}

    procedure spinning();
    begin
    {...spinning part here...}

      spunFlax := spunFlax + 28;
       
    end;

    {...more script content...}

    begin
      repeat
        if (spunFlax > FLAX_TO_SPIN) then
          terminateScript;
        Findingbank();
        Banking();
        GoingDownstairs();
        GoingToSpinningWheel();
        Spinning();
        GoingUpstairs();
      until (not isLoggedIn());
    end.

    Also, if using DTMs, please be sure to free them from memory when done with them! For example:

    Simba Code:
    procedure myDTMProcedure;
    var
      myDTM: integer;
    begin
      myDTM := DTMFromString('mbQAAAHicY2VgYOBgZmDgAuIXTAwMGkBaFIjNgGwpIHYGYg8gjgTiDZvWMNTG2jO0pXgydGf6MbSlejJIAvWjY0YsGAwAcboJ2w');
      {...using DTM...}
      freeDTM(myDTM);
    end;

    A breaking feature can be added by using a TTimeMarker, like so:

    Simba Code:
    //Globals
    const
      TIME_TO_BREAK_AT = 200000;

    var
      breakTimer: TTimeMarker;

    {...script content...}

    begin
      breakTimer.start();
      repeat
        if (breakTimer.getTime() > TIME_TO_BREAK_AT) then
        begin
          myBreakProcedure();
          breakTimer.reset();
          breakTimer.start();
        end;
        Findingbank();
        Banking();
        GoingDownstairs();
        GoingToSpinningWheel();
        Spinning();
        GoingUpstairs();
      until (not isLoggedIn());
    end.

    Let me know if this is unclear or if you have any further questions.
    Last edited by Clarity; 07-10-2015 at 05:17 PM.

  4. #4
    Join Date
    Dec 2014
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    13 Post(s)

    Default

    Thank you for the help! Right now i don't have that many time, but soon i will and i'll really try to make a well rounded good script that i can publish. If i have other questions i'll just ask it on this forum!

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
  •