Results 1 to 11 of 11

Thread: All In One Beginner Guide

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

    Default All In One Beginner Guide

    Welcome, this is my fourth tutorial, and it includes all you need to know as a beginner to start making your scripts.
    This isn't going to be the best guide you will ever see, I just hope it can help. Feedback appreciated.

    Contents

    1. Introduction
    2. Procedures and Functions
    3. Color Finding
    4. Option Choosing
    5. Inventory Commands
    6. Repeat the script
    7. Antiban
    8. All together now
    9. Conclusion


    Introduction

    Hey guys. I've been scripting for a few months now, and decided to try my hand at a all in one tutorial. This guide is for the complete beginner, so advanced scripters probably won't gather much from this. I hope by the end of this, you don't just copy/paste, but actually create your own from scratch.

    Procedures and Functions

    Alright, when I first started, I was confused here, I didn't really understand what the difference was. I'm going to try to explain it now.

    First off, variable types:
    Integer ~ A whole number
    String ~ One or more letters/numbers/characters.
    Tpoint ~ A point on the screen.
    TBox ~ It takes two points, and makes a box, using X1,Y1,X2,Y2, as the corners of the box.
    Boolean ~ Can only be True or False
    TPointArray ~ An Array of Tpoint, so multiple Tpoints in one Variable
    Array of -Variable here- ~ An Array of the variable you choose.
    2D arrays ~ An Array of an Array. (Confusing, I know)

    Now that we got that out of the way, on to procedures!

    Simba Code:
    procedure Mine;
    var
      Mined : Integer;
      s : String;
    begin
      //Code here
    end;

    Let's take a breakdown!
    Simba Code:
    Procedure Mine;
    This is the name of the procedure, and it's how you call it, which we will learn at the end of this chapter.
    Simba Code:
    var
      Mined : Integer;
      s : String;
    Var stands for Variables, so this is where you declare local variables, or variables that can only be edited inside that procedure.

    If you use it at the top of your script, you can use that variable throughout the whole script.

    Simba Code:
    begin
    end;
    This tells you what the procedure is doing, basicly.

    On to Functions!
    They are just like procedures, except they return a variable. Need an example?

    Simba Code:
    Function returnString:String;
    begin
      Result := 'Here is the result, or the variable returnString equals!';
    end;

    After you name it, you put :-Variablehere-, and then inside the script, use Result := to declare what it equals!

    So you could do something like this:
    Simba Code:
    Writeln(returnString);
    That would return:
    Simba Code:
    Here is the result, or the variable returnString equals!'
    Get it?
    You can place that with a Integer, Boolean, and anything else. It's most commonly seen as a Boolean, though.

    Time to go semi-advanced with this.

    Simba Code:
    procedure ReturnString(s:String);
    begin
      Writeln(s);
    end;
    You didn't declare s after the name, because you declared it IN the name! You can do this for Functions also.

    So, you would do this to call it!
    Simba Code:
    ReturnString('Here is the String');
    Then s equals 'Here is the String'!

    That sums it up for Functions and Procedures!

    Color Finding

    I perfer to use ACA to find colors. It seems much more accurate than FindColorTolerance.

    This below is for working on a bank. It can be used for ANYTHING. Just got to be creative.

    Here it is:
    We'll be using AutoColorAid to find the colors.
    The link can be found here.
    Alright. This is what how you need to set it up.
    Go to Client -> Find RS


    After you clicked two, click on the booths, click about three different booths, about 7 - 10 times each in different places, to get a good reading. Click "Mark Best Color" and if mostly only those are colored red, you did it! If say, the ground is lit, redo it with less points.
    This is my final picture:

    The color: That's the color you'll be needed. The first and second number I circled, we'll get to that in a minute.

    How to find the bank
    You got your info on the Autocolor, time to put it into code.
    Simba Code:
    function FindBankTeller(var x, y : Integer) : Boolean;
    var
       a : Integer;
      TPA  : TPointArray;
      ATPA : T2DPointArray;
      MP   : TPoint;
      tmpCTS : Integer;
      Box,SearchArea  : TBox;
    begin
      if not LoggedIn then Exit;
     tmpCTS := GetColorToleranceSpeed;
     ColorToleranceSpeed(2);
     SetColorSpeed2Modifiers(0.03,0.78);
     SearchArea := IntToBox((MSCX - 200),(MSCY - 100),(MSCX),(MSCY + 150));
     SMART_DrawBoxEx(True,SearchArea,clPurple);
      FindColorsSpiralTolerance(MSCX,MSCY,TPA,2313821,MSCX -200,MSCY - 100 ,MSCX,MSCY + 150,9);
      SortTPAFrom(TPA,point(MSCX,MSCY));
      ATPA := TPAtoATPAEx(TPA,15,15);
      for a := 0 to High(ATPA) do
      begin
        MP := MiddleTPA(ATPA[a]);
        Box := IntToBox((MP.x - 20),(MP.y - 20),(MP.x + 20),(MP.y + 20));
        SMART_DrawBoxEx(False,Box,clYellow);
        MMouse(MP.x,MP.y,4,4);
        if(WaitUpText('ank',750))then
        begin
          While(InvCount > 15) do
          begin
            x := MP.x; y := MP.y;
            Result := True
            SMART_ClearCanvas;
            Mouse(x,y,0,0,True);
            WaitFunc(@BankScreen, 10 + Random(15), 10000);
            Deposit(2,28,True);
            Writeln('Depotsitied');
            Antiban;
          end;
          Break;
        end;
      end;

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

    I'm not going to go over all of it, but I'll go over the parts you need to know.

    SetColorSpeed2Modifyers: The first number should be the red circled number, and the second the green.

    SearchArea: is defined as a Tbox, or three points. I used MSCX and MSCY to start the box, and them again to mark the end. The first two is the first corner of the box, the second is the last. MSCX/Y is Main Screen Center, then plus or minus X/y To make a box.

    SMART_DrawBoxEx: This draws the box on screen do you know what you're looking at. Set the first variable to True if you want it to clear the screen, or false to keep it there. Second variable is the name of the Tbox, third is the color (cl"ColorName").

    FindSpiralTolerance: You use MSCX,MSCY as the first two, then TPA, then the color, then where it searches, this is where painting the box comes in handy, so you know where it's looking. Those four that should usually be MSX1, MSY1,ect, should be the same thing you put in the box! The tolerance is off to the right of the AutoColorAid program(ACA). It's right under Main color. The - is not a minus sign, tolerance is always positive!

    WaitFunc: This waits for the BankScreen, which is @BankScreen. It waits 10 seconds, checking every 10 milliseconds, plus random 15.

    The rest you should be able to gauge what it does, and how to work it!


    How to use it

    You call it in a function like this
    Simba Code:
    if(-NameOfFunction-(x,y)) then //The (x,y) has to be after the name for it to work, that's where it saves the location to.
    begin
    //blah blah blah, remember, the banking is done IN the color finding function, so this is AFTERWARDS
    end;
    Choosing Options

    Alright, time to choose some options!

    To get the mouse over it, you use this:
    Simba Code:
    Mouse(x,y,4,4,mouseRight);
    This will move the mouse to x,y, with a randomness of 4, and then right click it. You can also use mouseLeft, if you just want it to skip right click, and just click it, which can then ignore the next step.

    You then use something like
    Simba Code:
    WaitOption('String to look for',3000);
    In the String to look for, it's looking for one of the options, so if you wanted it to say mine, you could use 'Mine' or 'ine' It has to capitalized correctly.
    It then waits for a maximum of 3 seconds, because it counts in milliseconds.

    You could use this for many different things.

    Now, if you perfer to just LeftClick, I would do this:
    Simba Code:
    Mouse(x,y,4,4,3);
    WaitUpText('Uptext',5000);

    It would move mouse, with randomness of 4, and then with the 3, it just moves it, and doesn't click.

    WaitUpText looks for the Uptext, or the text in the top left corner of the screen when you hover your mouse over it. 'Uptext' is what you're looking for, which needs to be capitalized correctly. It waits a maximum of 5 seconds.
    Then you could do.
    Simba Code:
    Mouse(x,y,4,4,3);
    if(WaitUpText('Uptext',5000)) then
      Mouse(x,y,0,0,mouseLeft);
    Which then clicks if it finds the uptext correctly!
    Inventory Commands


    It's nice to know these, so you know when to break loops and things.

    Simba Code:
    var
      Inventory:Integer;
    begin
      Inventory := InvCount
      if(Inventory > 20) then
      bank;
    end;

    Simba Code:
    WaitInvMinCount
    This procedure waits for the specified amount of items in the inventory. You'll see how to use it later.
    Simba Code:
    DropAllExcept
    Drops everything in inventory except which item slots.

    Simba Code:
    GetSystemTime
    Not really an inventory command, but oh well. When called, it gets the current time, simple. You'll see how I use it later, also.

    Just a small part of the guide, you can find more in the Inventory section of SRL.

    Repeating Script


    To repeat the script, you add all your functions in a mainloop:
    Simba Code:
    procedure Mainloop;
    begin
      WalkToOre;
      MineOre;
      WalkToBank;
      Bank;
    end;
    Something along the lines of that, with more advanced ones being obviously safer.

    To use it, go to your final begin..end

    Simba Code:
    begin
       SetupSRL
       repeat
        Mainloop;
       until(AllPlayersInactive);
    end;

    This just repeats the script until all the players are inactive.
    Antiban


    Antiban exists to keep us safe, so here's a quick runthrough.
    Simba Code:
    procedure Antiban;
    begin
      FindNormalRandoms;
      case Random(80) of
        0: RandomRClick;
        2: PickUpMouse;
        3: RandomMovement;
        4: BoredHuman;
        5: ExamineInv;
        7: SetAngle(SRL_ANGLE_HIGH);
        8: Wait(750 + random(750));
      end;
    end;
    This just does different things, at about a 1/10 chance of it happening. It also checks for randoms.

    All together now


    Alright! Let's make us a script!
    Here's the skeleton:
    Simba Code:
    program new;
    {$DEFINE SMART}
    {$i srl/srl.simba}
    {$i srl/srl/misc/paintsmart.simba}  
    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1; // This is set to the total amount of players (more on multiplayer later ;)), for now, just keep it set as 1
      NumberOfPlayers(HowManyPlayers); // This is a procedure in SRL which sets up player arrays (also, more on that later), this will always be the same
      CurrentPlayer := 0; // This is the player to start with; the first player will always be 0 (you'll find out when you learn all about arrays)

      Players[0].Name := ''; // Username
      Players[0].Pass := ''; // Password
      Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
      Players[0].Active := True; // Set to true if you want to use Player 0
      Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
      Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
    end;


    begin
      // These 4 lines HAVE to be set BEFORE you call SetupSRL;
      Smart_Server := 26;
      Smart_Members := False;
      Smart_Signed := True;
      Smart_SuperDetail := False;

      ClearDebug;
      SetupSRL;
      DeclarePlayers;
      LoginPlayer;
    end.

    Save that as Default script.
    (File > Save As Default)

    Alright, click run, and log in.

    We're going to be making a power chopper for Lumbridge.

    Start at a Willow tree, hatchet in first slot in inventory, or equipped.

    Lets see if you can do it without help, to see if you understood!

    Here is what I got:
    Simba Code:
    program Powerchopper;
    {$DEFINE SMART}
    {$i srl/srl.simba}
    {$i srl/srl/misc/paintsmart.simba}
    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1; // This is set to the total amount of players (more on multiplayer later ;)), for now, just keep it set as 1
      NumberOfPlayers(HowManyPlayers); // This is a procedure in SRL which sets up player arrays (also, more on that later), this will always be the same
      CurrentPlayer := 0; // This is the player to start with; the first player will always be 0 (you'll find out when you learn all about arrays)

      Players[0].Name := ''; // Username
      Players[0].Pass := ''; // Password
      Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
      Players[0].Active := True; // Set to true if you want to use Player 0
      Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
      Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
    end;
    procedure Antiban;
    begin
      FindNormalRandoms;
      case Random(80) of
        0: RandomRClick;
        2: PickUpMouse;
        3: RandomMovement;
        4: BoredHuman;
        5: ExamineInv;
        7: SetAngle(SRL_ANGLE_HIGH);
        8: Wait(750 + random(750));
      end;
    end;
    function FindTree(var x, y : Integer) : Boolean;
    var
       a,HowMany,Time : Integer;
      TPA  : TPointArray;
      ATPA : T2DPointArray;
      MP   : TPoint;
      tmpCTS : Integer;
      Box,SearchArea  : TBox;
    begin
      if not LoggedIn then Exit;
     tmpCTS := GetColorToleranceSpeed;
     ColorToleranceSpeed(2);
     SetColorSpeed2Modifiers(0.70,1.52);
     SearchArea := IntToBox((MSCX - 200),(MSCY - 100),(MSCX),(MSCY + 150));
     SMART_DrawBoxEx(True,SearchArea,clPurple);
      FindColorsSpiralTolerance(MSCX,MSCY,TPA,2635575,MSCX -200,MSCY - 100 ,MSCX,MSCY + 150,2);
      SortTPAFrom(TPA,point(MSCX,MSCY));
      ATPA := TPAtoATPAEx(TPA,15,15);
      for a := 0 to High(ATPA) do
      begin
        MP := MiddleTPA(ATPA[a]);
        Box := IntToBox((MP.x - 20),(MP.y - 20),(MP.x + 20),(MP.y + 20));
        SMART_DrawBoxEx(False,Box,clYellow);
        MMouse(MP.x,MP.y,4,4);
        if(WaitUpText('hop',750))then//Waits for Chop
        begin
          While(InvCount < 28) do
          begin
            x := MP.x; y := MP.y;
            Result := True
            SMART_ClearCanvas;
            Mouse(x,y,0,0,True);
            Time := GetSystemTime + 5000;
            While(Time > GetSystemTime) do
            begin
            HowMany := InvCount
             if(WaitInvMinCount((HowMany + 1),30000)) then //If you got a log, waits 30 seconds for it
             begin
                Writeln('Got logs');
                Writeln('So far so good');
                Time := GetSystemTime + 5000;//Resets time
                Continue; //Returns to top of the loop it's called in, so While(Time > GetSystemTime);
             end else
              Exit; //Exits procedure
             end;
            Antiban;
          end;
          if(InvCount = 28) then DropAllExcept([1]); //Drops everything
          Break;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2,0.2);
    end;
    procedure Mainloop;
    var
      x,y:Integer;
    begin
      FindTree(x,y);
      Antiban;
    end;
    begin
      // These 4 lines HAVE to be set BEFORE you call SetupSRL;
      Smart_Server := 26;
      Smart_Members := False;
      Smart_Signed := True;
      Smart_SuperDetail := False;

      ClearDebug;
      SetupSRL;
      DeclarePlayers;
      LoginPlayer;
      repeat
        Mainloop;
      until(AllPlayersInactive);
    end.

    A little buggy, but works pretty good! It powerchops, then drops.

    Conclusion


    If your reading this, than thanks for reading! I would love feedback/things to improve on! Until next time, ~NKN
    Last edited by NKN; 05-04-2012 at 12:40 AM.

  2. #2
    Join Date
    Apr 2012
    Posts
    350
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yay for scripting tutorial! I've read about 2 and a half scripting tutorials up until now..and I still don't know when to use var, boolean, etc. >.<
    Last edited by b_lone; 05-04-2012 at 12:53 AM.

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

    Default

    Alright, thanks. :P

  4. #4
    Join Date
    Dec 2011
    Location
    Berlin
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Cool guide I enjoyed it alot. Maybe you should add a TPA section in it as it is really needed and lots of people dont understand them.

    I will try to answer all Runescape related questions!

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

    Default

    I'll think about it. Should absolute beginners be learning what TPA's are at the start? xD

  6. #6
    Join Date
    Jan 2012
    Posts
    522
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Good tutorial for the rookies
    I learned from tutorials and they really help a lot if you're dedicated
    Previously known as "Phyaskou"

  7. #7
    Join Date
    May 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you! You helped me a lot.

  8. #8
    Join Date
    Mar 2012
    Location
    San Diego
    Posts
    760
    Mentioned
    4 Post(s)
    Quoted
    91 Post(s)

    Default

    Thanks for this! Will help me a lot on my first RS script

  9. #9
    Join Date
    May 2012
    Posts
    53
    Mentioned
    1 Post(s)
    Quoted
    10 Post(s)

    Default

    really helpful guide and really helped with variables

  10. #10
    Join Date
    May 2012
    Posts
    59
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    This tutorial is pretty good, slowly working my way through all the scripting tutorials and working on my own scripts as I gain more skills, thanks for this.

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

    Default

    bookmarked ty really nice tut.Gonna see if I can learn something with being think in the head and all.

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
  •