SRL Archive - OSR Outdated Tutorials

Labels Tutorial


Ejjman

2007-08-03 22:27:32

This is a tutorial on Labels, also known by some people as pointers…


I. What are they
II. How do I use them
III. Example usage of them
IV. Credits



I. WHAT ARE THEY
Labels are things that you can go back to if you do something wrong in a script. It is a word in bold, and, well, are just plain useful.

II. HOW DO I USE THEM

program Lost;
{.include SRL\SRL.scar}

label
TheLbl;

var
Count : integer;

begin
TheLbl:
repeat
Count := Count + 1;
wait(1000);
if(Count = 5)then goto TheLbl;
until(false);
end;

K. Let's look at this. There's its own spot to put labels.
label
Onelbl;
Twolbl;

Now, in the main loop, notice how the indenting is, and also, TheLbl: does not require an end;

III. EXAMPLE USAGE OF THEM
This is taking from my upcoming script.
begin
mmm := 0;
Misclick:
if(FindSuperSecretThingyICantSay(mx, my))then
begin
case random(3) of
0: ClickMQuick(True);
1: begin
ClickMQuick(False);
ClickOption('Attack', 1);
end;
2: begin
ClickMQuick(False);
ClickOption('Attack', 1);
end;
end;
if(not(ClickItem))then goto Misclick;

See, if it misclicks the object,then it will go back and try to click it again! See, it can be pretty useful and take spots of loops in some spots!

IV. CREDITS
Starblaster for teaching. :)



-Ejj

Esteban

2007-08-03 23:03:36

Cool tutorial Ejj. If i can find a way to use this in woodcutting to figure out it it actually clicked on the tree (i'm gussing by finding the red X when a tree is clicked), or if it misclicked, then it will reclick.

Pure 4 Life

2007-08-04 03:53:30

You will be making $13569401 a year in your future!

HeHe, loads of Z's :P

mastaraymond

2007-08-04 04:18:49

But, uuhh, what is wrong with freddies his tutorial ^^.

Anyway, gj.

~Raymond

Pancakes

2007-08-04 06:40:07

Nice tut. Mine was out before though? :p

Still, you explained it well.

Hugolord

2007-08-04 06:45:26

Excellently explained although a few pics would make it great :D

LordGregGreg

2007-08-04 11:10:44

I like your tutorial! Very well explained and all.
However, allot of these ppl are new to programming… and I'm not sure ( in their best interest) if it is a good idea to be teaching them this.

It is easier and simpler to use than the more common types of loops… however, I think its bad programing practice that can very quickkly makke your code unweildable, and well, un fixable.

Any sort of label system can be replaced by a loop (it has been proven, seriously, every one) and probably should.

Try googling it, i used to love labels too, but it really makes for much better coding if you dont use them.

Please don't let that obscure my point though, this is a great tutorial, and on very simple script, can be much quicker to code.

n3ss3s

2007-08-04 13:45:06

Ahh thanks.

Tim0suprem0

2007-08-04 14:37:09

Thanks, this is helpful! I've never used labels before, but now maybe I'll try or at least check out a few other tuts on it.

passiondrive

2007-08-04 14:59:08

I'll be sure to give these a test out, thanks for the tut!

Ejjman

2007-08-07 17:40:31

Crap, I looked for tuts that peple made of this, and I couldn't find any? I used the search button (:D) so I dunno. Sorry but ya.

Zezi

2008-04-01 11:03:42

Very usefull, i'm adding it into my script right now :) Are labels useful for mainloop failsafes, ie, if it's halfway through the script fails, but i find out i'm actually 2 procedure behind after i used a findsymbol to find i actually got stuck in the bank, and i've not actually walked up to the mining field yet, can i get it to restart from that?

I THINK that made sense? :)

JuKKa

2008-04-01 11:08:07

program Lost;
{.include SRL\SRL.scar}

label
TheLbl;

var
Count : integer;

begin
TheLbl:
repeat
Count := Count + 1;
wait(1000);
if(Count = 5)then goto TheLbl;
until(false);
end;

1) Remove the include ur not using it.
2) The last end should end with a DOT not a semicolon. Like this: End.
3) You cant use labels in loops. Line 15: [Error] (15:13): Invalid jump in script

Do some more research before making tutorials.

Else good job :P