Results 1 to 13 of 13

Thread: Complete noob needs help with simple script!

  1. #1
    Join Date
    Apr 2012
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Complete noob needs help with simple script!

    Alright, so here goes. I'm throwing myself at the mercy of you guys here.
    I didn't want to feel like a leecher so i attempted some tutorials on basic scripting, and although i feel like A LOT of it went over my head.. i managed to get the tree cutting script to work. I figured it'd be easy to apply that knowledge to a simple buying/banking script.

    well it wasn't for me :P Really, even reading the tutorials i have no clue what i'm doing other then what i'm told, so this will probably look like a COMPLETE MESS to you guys. Just, tell me where i went wrong? xD

    The idea was to have a simple script that finds the bank shop (at the lumbridge chest, I'm standing right next to it so no moving involved) buy "all" chocolate bars and bank them. I guess you can see what i had in mind but it doesnt quite translate :P


    program new;
    {$DEFINE SMART}
    {$i srl/srl.simba}

    Procedure DeclarePlayers;
    Begin
    Howmanyplayers :=1;
    Numberofplayers(howmanyplayers);
    CurrentPlayer :=0;

    Players[0].name :='';
    Players[0].pass :='';
    Players[0].nick :='';
    Players[0].pin :='';
    Players[0].Active:=True;
    End;

    Procedure Startup;
    begin
    MakeCompass('N');
    SetAngle(0);
    Writeln('Setting the compass');
    GameTab(Tab_Inv);
    end;


    procedure FindShop;
    Var x,y: integer;
    begin
    if findObj(x,y, 'hest', 5793906, 10)then
    begin
    mouse(x,y, 2,1, false);
    chooseoption('ood');
    end;
    end;

    Procedure BuyFood;
    var x, y: integer;
    begin
    if findObj(x,y, 'hoco', 1452102, 5)then
    begin
    mouse(x, y, 2, 1, false);
    chooseoption('all') ;
    end;
    end;

    Procedure BankChest;
    var x, y: integer;
    begin
    if findobj(x, y, 'hest', 5793906, 10)then
    begin
    mouse(x, y, 2, 1, true)
    If PinScreen then
    InPin(Players[CurrentPlayer].Pin);
    if findobj(x, y, 'eposit', 1854330, 5)then
    mouse(x, y, 2, 1, true)
    end;
    end;


    begin
    SetupSRL;
    ActivateClient;
    DeclarePlayers;
    LoginPlayer;
    Startup;
    FindShop;
    BuyFood;
    Bankchest;
    end.
    So yeah, It gets about as far as opening the shop (if im lucky before completely failing to do anything worthwhile xD)

  2. #2
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Try not to use FindObj.
    Maybe the color was off? You could try using AVA, check out Kyle Undefined's "Your First Script" to figure out how to use it, it's a lot more accurate.

  3. #3
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Ok first of all, I'm going to recommend as this is your first script, you should be using at least FindObjCustom rather than FindObject. It works exactly the same except for you can search for multiple uptext and most importantly multiple colors. It works like this:
    Simba Code:
    FindObjCustom(x, y, ['att', 'ack'], [123456, 345678], 5);

    Also, another flaw I noticed was that in your banking procedure I'm not sure exactly what you're doing with this line:
    Simba Code:
    If findobj(x, y, 'eposit', 1854330, 5)then
      mouse(x, y, 2, 1, true)
    Are you trying to click the Deposit All button on the Bankscreen? If so you can use a simple SRL function called DepositAll;

    Also, I recommend you make DTMs to recognise the chocolate bar as a LOT of items have the same brown color, hence you'll end up having your mouse moving around in a spasm trying to find the right uptext. If you want to learn how to make DTMs you can find a handful of guides in the tutorial section.

  4. #4
    Join Date
    Apr 2012
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you, yeah i was trying to go deposit with my limited knowledge, it seemed like it would have worked

    Was everything else in the banking section ok? I'm not even sure i used "pinscreen" in the correct manner to be honest - again another one to read up on

    I'll look at further guides. I tried a DTM tutorial that was meant to be "really simple" and the whole thing went over my head. Maybe i was just tired ^^

    again thanks

  5. #5
    Join Date
    Apr 2012
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Okay, so i was following a tutorial, and started my hand at making the basics of the script entirely from memory:

    program new;
    {$i srl/srl.simba}



    Procedure DeclarePlayers;
    Begin
    Howmanyplayers :=1;
    Numberofplayers(howmanyplayers);
    CurrentPlayer :=0;

    Players[0].name :='';
    Players[0].pass :='';
    Players[0].nick :='';
    Players[0].Active:=True;
    End;



    // ACA data
    function treecolor: Integer;
    var
    arP: TPointArray;
    arC: TIntegerArray;
    tmpCTS, i, arL: Integer;
    X, Y, Z: Extended;
    begin
    tmpCTS := GetColorToleranceSpeed;
    ColorToleranceSpeed(2);
    SetColorSpeed2Modifiers(0.14, 0.44);

    FindColorsSpiralTolerance(MSCX, MSCY, arP, 3491920, MSX1, MSY1, MSX2, MSY2, 2);
    if (Length(arP) = 0) then
    begin
    Writeln('Failed to find the color, no result.');
    ColorToleranceSpeed(tmpCTS);
    SetColorSpeed2Modifiers(0.2, 0.2);
    Exit;
    end;

    arC := GetColors(arP);
    ClearSameIntegers(arC);
    arL := High(arC);

    for i := 0 to arL do
    begin
    ColorToXYZ(arC[i], X, Y, Z);

    if (X >= 5.69) and (X <= 6.82) and (Y >= 6.01) and (Y <= 7.18) and (Z >= 3.97) and (Z <= 4.78) then
    begin
    Result := arC[i];
    Writeln('AutoColor = ' + IntToStr(arC[i]));
    Break;
    end;
    end;

    ColorToleranceSpeed(tmpCTS);
    SetColorSpeed2Modifiers(0.2, 0.2);

    if (i = arL + 1) then
    Writeln('AutoColor failed in finding the color.');
    end;




    //Finds the Tree, and clicks it
    Function FindTree:Boolean;
    var
    x, y: Integer;
    begin
    FindNormalRandoms;
    x:=MSCX ;
    Y:=MSCY;
    If findObjTPA(x, y, treecolor, 5, 1, 10, 50, 300, ['chop'])then
    begin
    Mouse(x, y, 2, 2, true);
    end;
    end;



    begin
    SetupSRL;
    ActivateClient;
    DeclarePlayers;
    FindTree;
    end.


    Basically just wanted the script to find a tree and click. It finds the tree perfectly but never clicks, just hovering over each one before stopping. why?
    Last edited by rjk1990; 04-16-2012 at 08:06 PM.

  6. #6
    Join Date
    Mar 2012
    Location
    Over there
    Posts
    840
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    You are missing an end; in your FindTree function. Put 1 more end;. You need to end case statements.

  7. #7
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    You need one more end on your FindTree function

    EDIT: Ninja'd by TotalKillz

  8. #8
    Join Date
    Mar 2012
    Location
    Over there
    Posts
    840
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

  9. #9
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Well did you fix his Standards?
    Simba Code:
    program new;
    {$i srl/srl.simba}

    procedure DeclarePlayers;
    begin
      Howmanyplayers :=1;
      Numberofplayers(howmanyplayers);
      CurrentPlayer :=0;

      Players[0].name :='';
      Players[0].pass :='';
      Players[0].nick :='';
      Players[0].Active:=True;
    end;



    // ACA data

    function TreeColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.05, 0.08);
      FindColorsSpiralTolerance(MSCX, MSCY, arP, 2374992, MSX1, MSY1, MSX2, MSY2, 7);
        if (Length(arP) = 0) then
        begin
          Writeln('Failed to find the color, no result.');
          ColorToleranceSpeed(tmpCTS);
          SetColorSpeed2Modifiers(0.2, 0.2);
          Exit;
        end;

      arC := GetColors(arP);
      ClearSameIntegers(arC);
      arL := High(arC);
      for i := 0 to arL do
        begin
          ColorToXYZ(arC[i], X, Y, Z);
          if (X >= 2.81) and (X <= 8.83) and (Y >= 2.76) and (Y <= 8.55) and (Z >= 1.34) and (Z <= 3.79) then
          begin
            Result := arC[i];
            Writeln('AutoColor = ' + IntToStr(arC[i]));
            Break;
          end;
        end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
      if (i = arL + 1) then
        Writeln('AutoColor failed in finding the color.');
    end;


    //Finds the Tree, and clicks it
    function FindTree:Boolean;
    var
      x, y: Integer;
    begin
      FindNormalRandoms;
      x:=MSCX ;
      Y:=MSCY;
        if findObjTPA(x, y, TreeColor, 5, 1, 15, 60, 600, ['cho']) then
        begin
          GetMousePos(x, y);
            case random(2) of

            0: mouse(x, y, 5, 5, true);

            1: begin
                 mouse(x, y, 5, 5, false);
                 waitoption('hop', 600);
               end;
            end;
        end;
    end;


    begin
      SetupSRL;
      ActivateClient;
      DeclarePlayers;
      LoginPlayer;
      FindTree;
    end.

    Ok so I made one mistake I can see, who cares

  10. #10
    Join Date
    Mar 2012
    Location
    Over there
    Posts
    840
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    Oh snap. Brb making custom TPA object finding for his script. Jk lol.

  11. #11
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Quote Originally Posted by TotalKillz View Post
    Oh snap. Brb making custom TPA object finding for his script. Jk lol.
    Lol at this rate we're gonna make him a flawless script

  12. #12
    Join Date
    Mar 2012
    Location
    Over there
    Posts
    840
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    Wow lol. I'm looking at that code and realized I don't follow normal standards. o.O Never knew you indented if statements....brb tutorial section lmao.

  13. #13
    Join Date
    Apr 2012
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Lol, thanks. I missed the end; (didn't know about the case thing) Thanks for being helpful and not flaming me for silly mistakes.

    Okay, so i got the script to find a tree perfectly and click it from memory even after logging in and out. I call that a win after one day xD

    as to above poster, I'm entirely sure my standards are not correct due to completely messing up and deleting lines xD
    Last edited by rjk1990; 04-16-2012 at 08:26 PM.

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
  •