PDA

View Full Version : The guide/handbook to the usefull procedures and functions of SRL



Awkwardsaw
12-19-2010, 02:22 AM
this tutorial is really just here to show you, as a begining scripter, where to begin in creating a script :). A few years ago when i first started scripting, my biggest problem was finding the procedures i needed to complete a task, such as "how do i wait to stop moving after i clicked on the minimap", or "its nice that the bank is open, but whats next? how do i deposit or withdraw?". This small tutorial should help answer questions like that. Here, I will expect you to know the basics of scripting, and to master the beginers section of Tutorial Island :)

here is a list of every procedure i will cover:

{$include srl/srl.scar}
//Anti-Ban
// * procedure RandomRClick; // by phantombmx/EvilChicken!, idea by NaumanAkhlaQ
// * procedure HoverSkill(Skill: String; Click: Boolean); // by Dankness extended by Cheesehunk and fixed by Ron
// * procedure PickUpMouse; // by dark_sniper
// * procedure RandomMovement; // by Krazy_Meerkat
// * procedure BoredHuman; // by WT-Fakawi
// * procedure ExamineInv; // by R1ch
// * procedure RandomAngle(HowToEnd : Variant); // by R1ch
// * function LevelUp : Boolean; // by R1ch

//Bank
// * procedure Deposit(SlotFrom, SlotTo: Integer; vType: Variant); // * by PPLSUQBAWLZ / Stupid3ooo
// * function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean; // * by Starblaster100, Town, Wizzup? and Narcle
// * procedure DepositAll; // * by ZephyrsFury
// * procedure CloseBank; // * by Starblaster100
// * function OpenBankFast(Location: String): Boolean; // * by Wizzup?, Nielsie95 & N1ke!
// * function OpenBankNPC: Boolean; // * by Home

//Flag
// * function FFlag(Dist: Integer): Boolean; // by Wizzup?, WT-Fakawi, and ZephyrsFury
// * function Flag: Boolean; // by Nava2
// * procedure MouseFlag(X, Y, rX, rY, FlagDist: Integer); // by EvilChicken!

//Gametab
// * function GameTab(Tab: Integer): Boolean; // by ZephyrsFury
// * function GetCombatLevel: Integer; // by Nielsie95
// * procedure Retaliate(AutoRet:Boolean); // By WT-Fakawi & n3ss3s
// * function GetSkillInfo(Skill: Variant; Amount: Boolean): Integer; // by Raymond
// * function IsResting: Boolean; // by Sabzi
// * function GetMMLevels: integer; // by Raymond / Wizzup? / Sabzi
// * function XpTillNextLevel(Skill: Variant): Integer; // by Nielsie95
// * function SetRun(Run: Boolean: Boolean; // by Wizzup? and EvilChicken!
// * function SetRest: Boolean; // by ZephyrsFury
// * function RestUntil(Energy: Integer): Boolean; // by ZephyrsFury

//Inventory
// * function InvCount: Integer; // by RsN
// * function InvEmpty: Boolean; // by WT-Fakawi
// * function InvFull: Boolean; // by RsN
// * procedure DropItem(i: Integer); // by Lorax
// * Procedure DropPattern(which: integer); // by Rasta Magician
// * procedure DropAll; // by Rasta Magician
// * function ItemActivated(Slot: Integer): Boolean; // by marpis

//Login
// * function ExitToLobby; // by Starblaster100 and Raymond
// * function Logout: Boolean; // by IceFire908
// * function LogInPlayer: Boolean; // by The SRL Team
// * function NextPlayerIndex: Integer; // by Dankness, Ron, Raymond & ZephyrsFury
// * function RandomPlayerIndex: Integer; // by Dankness, Ron, Raymond & ZephyrsFury
// * function SwitchToPlayer(PlayerNo: Integer; Active: Boolean): Boolean; // by Dankness, Ron, Raymond & ZephyrsFury
// * procedure NextPlayer(Active: Boolean); // by ZephyrsFury
// * procedure RandomNextPlayer(Active: Boolean); // by ZephyrsFury

//Map walk
// * function MakeCompass(Direction: string): Boolean; // by nielsie95
// * procedure SetAngle(Highest : Boolean); // by Raymond, edit by NaumanAkhlaQ
// * procedure ClickNorth(AngleHigh: boolean); // by R1ch
// * function RadialWalkEx(var TPA: TPointArray; cx, cy, TheColor, tol, StartRadial, EndRadial, Radius: Integer): Boolean; // by nielsie95
// * function RadialWalk(TheColor, StartRadial, EndRadial, Radius, Xmod, Ymod: Integer): Boolean; // by nielsie95
// * function RadialWalkTolerance(TheColor, StartRadial, EndRadial, Radius, Xmod, Ymod, Tol: Integer): Boolean; // by nielsie95
// * function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray; // by footballjds, NaumanAklaQ, Nava2 & Cazax
// * function GetMiniMapDots(WhatDot: String): TPointArray; // by Nava2
// * function CountMiniMapDots(WhatDot: String): integer; // by Nava2

//Mouse
// * procedure MMouse(x, y, rx, ry: integer); // by BenLand100
// * procedure Mouse(mousex, mousey, ranx, rany: Integer; left: Boolean); // by Mutant Squirrle
// * function DidRedClick: Boolean; // by Rasta Magician
// * function DidYellowClick: Boolean; // by Rasta Magician

//Object
// * function FindObjRecord(var fx, fy: Integer; AutoInfo: TAutoColorInfo): Boolean; // By Sumilion
// * function FindObjTPA(Var x, y: Integer; color, tol, cts, ObjWidth, ObjHeight, minCount: Integer; UpText: string): Boolean; // By Wizzup
// * function FindObjTPAMulti(var X, Y: integer; Color: TIntegerArray; Tol, CTS, ObjWidth, ObjHeight, minCount :Integer; UpText: TStringArray): Boolean; // By: Torrent of Flame based on FindObjTPA

//Players
// * function LoggedIn: Boolean; // by WT-Fakawi
// * procedure NumberOfPlayers(Number: Integer); // by BenLand100 & Wizzup?
// * function AllPlayersInactive: Boolean; // by ZephyrsFury

//Symbol
// * function FindSymbol(var rx, ry: Integer; Name: String): Boolean; // * by Stupid3ooo
// * function FindSymbolIn(var rx, ry: Integer; Name: string; xs, ys, xe, ye: Integer): Boolean; // * by Starblaster100, based on the ideas of Stupid3ooo
// * function FindSymbolsIn(var AnsTPA: TPointArray; SymbolName: string; x1, y1, x2, y2: integer): Boolean; // * by lordsaturn

//Text
// * function srl_Explode(str, del: string): TStringArray; // by mixster
// * function srl_Implode(Pieces: TStringArray; Separator: string): string; // * by ZephyrsFury & mixster
// * procedure TypeSend(Text: String); // by N1ke!
// * function AddMistakes(Orig: string; Chance: Integer): string; // by ZephyrsFury
// * function GetUpText: String; // by Freddy1990
// * function IsUpText(UpText: String): Boolean; // by Masquerader / Nielsie95 / Freddy1990
// * function IsUpTextMultiCustom(Text: TStringArray): Boolean; // by Starblaster100 / Nielsie95 / Freddy1990
// * function ChooseOptionMulti(Text: TStringArray): Boolean; // by Wizzup? modified by N1ke!
// * function ChooseOption(txt: String): Boolean; // by Stupid3ooo, modded by Sumilion
// * Function OptionsExist(txt: TStringArray; MoveMouse: boolean): boolean; // by Rasta Magician

//Timing
// * function MsToTime(MS, StrType: Integer): string; // by ZephyrsFury, Nava2, and Rasta Magician
// * function TimeRunning: String; // by Rasta Magician
// * procedure MarkTime(var TimeMarker: Integer); // by Stupid3ooo
// * function TimeFromMark(TimeMarker: Integer): Integer; // by Stupid3ooo
// * function TheTime : string; // by RsN
// * function TheDate(DateFormat : Integer) : String; // by Ron & Nava2
// * function WaitOption(S: String; Time: Integer): Boolean; // by N1ke!
// * function WaitUptext(S: String; Time: Integer): Boolean; // by N1ke!
// * function WaitInvMaxCount(Count, MaxTime: integer): boolean; // by Rasta Magician
// * function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean; // by Rasta Magician, fixed by TRiLeZ

yes, the list is huge, but most are simple, and only require an example to be explained :D

Pro-Tip: to quickly browse the tutorial, use ctrl+f and search the section titles to quickly find the section you want :)

Contents:
- [1] Anti-Ban
- [2] Bank
- [3] Flag
- [4] Gametab
- [5] Inventory
- [6] Login
- [7] Map walk
- [8] Mouse
- [9] Object
- [10] Players
- [11] Symbol
- [12] Text
- [13] Timing

- [1] Anti-Ban
The anti-ban section has your basic antiban functions to protect you from the ban-hammer.
//Anti-Ban
// * procedure RandomRClick; // by phantombmx/EvilChicken!, idea by NaumanAkhlaQ
// * procedure HoverSkill(Skill: String; Click: Boolean); // by Dankness extended by Cheesehunk and fixed by Ron
// * procedure PickUpMouse; // by dark_sniper
// * procedure RandomMovement; // by Krazy_Meerkat
// * procedure BoredHuman; // by WT-Fakawi
// * procedure ExamineInv; // by R1ch
// * procedure RandomAngle(HowToEnd : Variant); // by R1ch
// * function LevelUp : Boolean; // by R1ch

example:

procedure AntiBan(randomness : integer);
case random(4 + randomness) of
0: RandomRClick;
1: PickUpMouse;
2: RandomMovement;
3: BoredHuman;
4: RandomAngle(false);
end;
LevelUp;
end;

assuming you know cases, this is pretty self explanitory, a case wich chooses a random function set by the user. Fortuanitly, the function names are detailed, and should be easy to figure out what each does :)

the only one that should need explaining is "LevelUp". what this does is check if you gained a level, by checking for the popup message in the chat box. this then clicks continue and does a little wait so you begin doing what you where. this is really usefull :)

- [2] Bank
Banking is what you make of it. Banking in a script can be really simple, just to get the job done, or it can be MASSIVE and complex, to make damn sure you get the correct materials in your inventory.

//Bank
// * procedure Deposit(SlotFrom, SlotTo: Integer; vType: Variant); // * by PPLSUQBAWLZ / Stupid3ooo
// * function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean; // * by Starblaster100, Town, Wizzup? and Narcle
// * procedure DepositAll; // * by ZephyrsFury
// * procedure CloseBank; // * by Starblaster100
// * function OpenBankFast(Location: String): Boolean; // * by Wizzup?, Nielsie95 & N1ke!
// * function OpenBankNPC: Boolean; // * by Home


Ive had scripts where the banking was literally:

function bank : boolean;
begin
if not openbanknpc then exit;
depositall;
result := invempty;
end;

i've also had scripts that where ~200+ lines long, to make sure i had the logs where they needed to be, the bow string, to make sure i had a knife in the inventory, and that i had enough materials to do an other load, not to mention all the script progress stats and stuff, so its very important to know how to effectivly use the banking functions :)

procedure Deposit(SlotFrom, SlotTo: Integer; vType: Variant);

Deposit works very nice for scripts such as fletching, woodcutting, fishing, ect because most of the time, you have everything in a set place within your inventory.

The parameter SlotFrom is the first inventory slot to be deposited
SlotTo is the last spot
vType is the way it will be deposited:
True means it will deposit all the items in and inbetween those slots until they are empty.
False means it will click each item for every slot

so, lets say you where woodcutting, and you know for sure you have a full inventory, with a hatchet in your first inventory spot. you would use

Deposit(2, 28, true);

procedure DepositAll;

this is really simple(and awesome). all it does is click the deposit all button on the bank screen to deposit all your inventory items fast and effective. only use this if your sure your inventory doesnt have anything you need!

function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;

WithdrawEx will withdraw an item from the bank, using Column, Row, and Uptext to find the item. easy as that :p

Col is what column the item you want is in, starting at 0
Row is what row the item you want is in, starting at 0
Amount is how many items you want withrawed.
Uptexts is just used as a failsafe to makesure its withdrawing the item you want, and not the random fishes that are next to w/e ;)

let's say your making a bow stringing script, so far the banking procedure would be:


procedure bank;
begin
openbanknpc; //opens bank by finding an npc
depositall; //we need to deposit everything in our inventory
withdrawex(0, 0, 14, ['bow', 'ring']); //withdraws 14 from the first bank slot, if the uptext includes the strings "bow" or "ring"
withdrawex(1, 0, 14, ['bow', 'ring']); //same as above, except it withdraws from the second column, first row
end;

this is all fine and dandy, but you just have to make sure that the slots have the correct type unstrung bows you want, and doesnt have anything else that includes "ring". I would personally use dtms, or blacklisting for more accurate results, but just using withdrawex can work in most situations :)

procedure CloseBank;

really simple. it closes the bank screen

function OpenBankFast(Location: String): Boolean;
once again, you should know that this opens the bank by finding the bank booth.
Valid arguments are:

'feb', 'falador east bank'
'fwb', 'falador west bank'
'veb', 'varrock east bank'
'vwb', 'varrock west bank'
'db' , 'draynor bank'
'akb', 'al-kharid bank'
'eb' (Edgeville Bank)
'ctb', 'catherby bank'
'clt', 'camelot bank'
'nab', 'north ardougne bank'
'sab', 'south ardougne bank'
'ynb', 'yanille bank'
'ngb', 'north gnome bank'
'sgb', 'south gnome bank'
'wgb', 'warrior guild bank'
'fgb', 'fishing guild bank'

I prefer findbanknpc, but i always use this as a failsafe, just in case :)

function OpenBankNPC: Boolean;
already explained, this opens the bank by searching for the banker. i prefer this for the main method of opening a normal bank :D

- [3] Flag
You know that red flag on the minimap whenever you move somewhere on runescape? well thats what this section is about! this is very short and easy, so i'll get to it.

function Flag: Boolean;
Simple but effective. all this does is wait until there is no longer a flag on the minimap(or when you stop moving). no setting up, no math or guessing, this will get the job done.

function FFlag(Dist: Integer): Boolean;
FFlag is just like Flag, except it waits untill you are a certain amount of pixels away from the flag, determined by Dist. this is good when being used in the middle of a path, so you can keep moving without any stopping

procedure MouseFlag(X, Y, rX, rY, FlagDist: Integer);
i love this procedure.

All it is, is the procedure Mouse(explained later in the thread), with FFlag, all wrapped up into one line :)

its used when making your own walking path, such as ddtms, tpas, symbols, ect. but actually walking is a different tutorial all together ;)

X stands for the X coordinate on the screen,
Y stands for the Y ccoordinate on the screen
rX is the randomness added to the X coord
rY is the randomness added to the Y coord
FlagDist is the distance from the flag to go to before moving on, such as FFlag.

all it does, is it will turn

mouse(x, y, 5, 5, true);
fflag(3);

to:
MouseFlag(X, Y, 5, 5, 3);

- [4] Gametab
Gametabs are those buttons on your right interface on rs. they let you switch between Inventory, Skills, Combat, Equipment, it also covers the Running, Resting, LP, and prayer, as well as many other things :)

//Gametab
// * function GameTab(Tab: Integer): Boolean; // by ZephyrsFury
// * function GetSkillInfo(Skill: Variant; Amount: Boolean): Integer; // by Raymond
// * function IsResting: Boolean; // by Sabzi
// * function XpTillNextLevel(Skill: Variant): Integer; // by Nielsie95
// * function SetRun(Run: Boolean: Boolean; // by Wizzup? and EvilChicken!
// * function SetRest: Boolean; // by ZephyrsFury
// * function RestUntil(Energy: Integer): Boolean; // by ZephyrsFury


function GameTab(Tab: Integer): Boolean;
This is the basic of it all. All this function does is switch between game tabs.

the nice guys here at srl made these things in the Globals.scar file called constants. these constants make it easier for guys like you and me(scripters) to find things. anyways, in this file there is a list of constants that where made specificly for Gametab:
const
tab_Combat = 21;
tab_Stats = 22;
tab_Quest = 23;
tab_Diary = 24;
tab_Inv = 25;
tab_Equip = 26;
tab_Prayer = 27;
tab_Magic = 28;
tab_Objectives = 29;
tab_Friends = 30;
tab_Ignore = 31;
tab_Clan = 32;
tab_Options = 33;
tab_Emotes = 34;
tab_Music = 35;
tab_Notes = 36;
tab_LogOut = 37;

So, how do they work? well, very simple really ;). they made it so instead of having to remember what numbers to put into the gametab parameter, all you do is type in the constant, like such:


gametab(tab_Inv); //switches to the gametab for inventory
gametab(tab_Stats); //switches to the gametab for stats
gametab(tab_LogOut); //switches to the tab to logout
and so on

function GetSkillInfo(Skill: Variant; Amount: Boolean): Integer;
this function should always be used in any decent progress report. what this does is, it finds out what skill level a certain skill is, and results in that number

this function also has its nice constants, to help you remember what you need :)

const
skill_Attack = 1;
skill_Strength = 2;
skill_Defence = 3;
skill_Range = 4;
skill_Prayer = 5;
skill_Magic = 6;
skill_Runecrafting = 7;
skill_Hitpoints = 8;
skill_Agility = 9;
skill_Herblore = 10;
skill_Thieving = 11;
skill_Crafting = 12;
skill_Fletching = 13;
skill_Slayer = 14;
skill_Mining = 15;
skill_Smithing = 16;
skill_Fishing = 17;
skill_Cooking = 18;
skill_Firemaking = 19;
skill_Woodcutting = 20;
skill_Farming = 21;
skill_Construction = 22;
skill_Hunting = 23;
skill_Summoning = 24;

the first parameter should be easy, all you do is fill it in with the skill you want, such as skill_Fletching

the next one though is a little tricky. what it is, is a boolean.
Amount = True, will return the current, or top number
Amount = False, will return the actual, or bottom number

example: lets say we are fletching, and somehow our skill got drained by 5 levels, so its at 85/90
GetSkillInfo(skill_Fletching, true)
will return 85, where if we replace true with false, it will return 90

function XpTillNextLevel(Skill: Variant): Integer;
an other good one for progress reports, all it does is return the xp till the next level for the given skill. once again, just fill in Skill with the needed constant

function IsResting: Boolean;
all this does is return true or false whether or not you are resting or not

function RestUntil(Energy: Integer): Boolean;
An other good one for scripts that do a lot of running around(pun intended)
simply, this will rest until you have a certain amount of energy, set by the parameter, Energy. honestly, i would let the user decide if he wants to use this, because sometimes its faster just to walk than waiting every trip to get the energy up :)

function SetRun(Run: Boolean) : Boolean;



please post on how i can improve what i already have. i plan on adding colour and more neatness at a later date :p

Awkwardsaw
12-19-2010, 02:23 AM
I might need this post later, and the next one, just incase ;)

Awkwardsaw
12-19-2010, 02:24 AM
saved

KingKong
12-19-2010, 03:56 AM
Shouldn't this be in Tutorial for beginners? As for the feedback, I think you've included most of the functions/procedures used by beginners, but I see that they are all color functions, perhaps you could put in some reflection stuff as well and then point out the differences between them?

Awkwardsaw
12-19-2010, 02:03 PM
no, i need people to understand the basics of scripting, this is just showing what functions you can use. the intermediate section is for people who are just learning how to script in RS. as for reflection, i dont see it nessesary for beginers to know, as color does just fine

Frement
12-19-2010, 02:06 PM
In my opinion this should be in beginners section.

Awkwardsaw
12-19-2010, 02:53 PM
"Tutorial for Beginners - If you are just starting scripting, these tutorials are the place to start"

"Tutorial for Intermediates - Wish to know how to code your own script from start to end? This is the place to find out all about SCAR and SRL"

i find it fits intermediates more

KingKong
12-20-2010, 10:34 AM
as for reflection, i dont see it nessesary for beginers to know, as color does just fine

Color works fine until a certain point, after which it can be really hard to do something that could be done in a few lines with reflection(like walking for example)

Awkwardsaw
12-20-2010, 04:30 PM
Color works fine until a certain point, after which it can be really hard to do something that could be done in a few lines with reflection(like walking for example)

walking is the only thing that comes to mind that as of right now, reflection can do better than color, and even then, color can do walking just fine if you get the right colors ;)

Frement
12-20-2010, 04:36 PM
Walking is almost as small as reflections? RadialRoadWalk(); takes 1 line, after that just Flag(); And there it is, you have walked to somewhere, now just making failsafes, that takes more space then reflection true, but the walking is as easy in both. There are more advanced walking methods that are longer and harder, but hey, there are things in reflection that are harder.

KingKong
12-20-2010, 11:10 PM
Radialroadwalk is only good if the colors on the minimap are not the same as each other(as is the case when walking in places such as desert, mining guild or wilderness). The reason I said reflection would be easier for a beginner/intermediate is that it does not require too much failsafes that color does and so they can make a reasonably good script until they get the hang of things.

Awkwardsaw
12-20-2010, 11:44 PM
Radialroadwalk is only good if the colors on the minimap are not the same as each other(as is the case when walking in places such as desert, mining guild or wilderness). The reason I said reflection would be easier for a beginner/intermediate is that it does not require too much failsafes that color does and so they can make a reasonably good script until they get the hang of things.

deserts are the easiest :p make sure the compass is north, and be specific on the radials. anyways, the reason im not including reflection is because its not really apart of SRL IMO, else it would be included in the main srl include, and not a separate folder

KingKong
12-24-2010, 07:10 AM
The one basic problem with radial walk is that it will only work if the compass is the same as it was when angles were measured, if it changes quite a bit then its no use, but with reflection, the compass angle doesn't matter.

PhaseCode
12-30-2011, 09:26 PM
This is so useful, thanks so much ~

GuthixBoss1
01-09-2013, 05:57 PM
Thank you for this. :D

SOUPalmighty
01-11-2013, 12:25 AM
Huge help thank you vary much