SRL Archive - Discussions and Debates

How did you guys (fakawi, wissup?..etc) learn to script so good?


JAD

2007-05-06 16:14:11

Sorry for making so many threads in the SRL discussions forum, but I have a few questions :p

When I make a script, am I doing the noobiest thing ever using if(FindColorTolerance then MMouse if IsUpText then Mouse? (Hope that made sense) Because when you look at a pro script, its got all this try this except and for I := I-4 do and things like that. This stuff just confuses me, and I'm wondering if its better to make my scripts a lot more complex like the pros, and how to learn it?

There really aren't any tutorials for me to read now, so I don't know what to do. I would love to improve my scripting given the opportunity; I have all the time in the world to read, I just need to know what to read/do :p

Thanks again.

~JAD

shaunthasheep

2007-05-06 17:21:56

try, except, end is just to catch errors.
Use FindObj? Or other object functions to find stuff.

nielsie95

2007-05-06 17:22:41

Would you like me to make a tutorial about try + except and for i:= 0 to .. do?
I learnt it by looking at other people's scripts and a lot of trying ..

bullzeye95

2007-05-06 17:26:50

Yeah try..except is to catch things like Runtime Errors and stuff like that (the stuff that usually makes the script stop). For loops are basically to do something a certain number of times. They do have other uses, but that's the main use. For example
for I:= 1 to 5 do
writeln(IntToStr(I));
That would write I 5 times.

Even though you probably already knew that stuff, and just wanted to know a good way to use it…

Ejjman

2007-05-06 18:06:56

From: bullzeye95
Yeah try..except is to catch things like Runtime Errors and stuff like that (the stuff that usually makes the script stop). For loops are basically to do something a certain number of times. They do have other uses, but that's the main use. For example
for I:= 1 to 5 do
writeln(IntToStr(I));
That would write I 5 times.

Even though you probably already knew that stuff, and just wanted to know a good way to use it…


Um what?

Off the top of my head, that would return 12345. Explain it good. The reason for this is because for I := 0 to 5 do
begin
writeln(IntToStr(I));
end;

Ok now look.

For is like saying umm….like, while I is gonna equal 1 to 5 do this stuff. So it will go trhough your begin..end. stuff as I := 1 like, run this.

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

procedure RunMe;
begin
for I := 0 to 5 do
begin
writeln(IntToStr(I));
end;
end;

begin
SetupSRL;
RunMe;
end.

See. That is really simple. I just changes as what you have. :) Have fun, and I recently started using this stuff lots they are a blast. :)

Abyssal

2007-05-06 18:29:16

Ejj, i:= 1 to 5 do writeln(inttostr(i) wouldnt return 12345, it would have a space in between in.

Also, with a simple to .. do statement you don't need to setupsrl. You don't even have any SRL procedures in there! :P

bullzeye95

2007-05-06 18:33:18

Sorry I should've been more clear. It would write the VALUE of I 5 times.

JAD

2007-05-06 19:03:59

thanks guys. This is what I'm confused on though.. Your not declaring what I =s right?? And your not adding 1 to it or anything, so why/how does I = 1, then 2..etc when your not even adding anything to it?

Sorry to sound like a noob, but a lot of good scripters do things like that and if I knew it it would help me :p

And as for using FindObj, no offense to whoever wrote it, but I think its a sort of noobish function. I don't really like it, and tarajunky said the same thing when I posted my function FindColorArea. Really, is there a difference between looking for a color, moving the mouse too it, checking the up text and then clicking? Because from what I know.. Thats all FindObj does too.

rkroxpunk

2007-05-06 19:06:22

Well as a scripting master (sorry there's just no point in denying it) I can tell you that it's absolutely fine to use findcolor and MM etc. Don't worry one day you might start to, err have some skill? :D but for now just be happy that you're posting in the same thread as me :D :D :D there's my 2 cents - even tho 1c coins expired ages down here :confused:

JAD

2007-05-06 19:11:59

From: rkroxpunk
Well as a scripting master (sorry there's just no point in denying it) I can tell you that it's absolutely fine to use findcolor and MM etc. Don't worry one day you might start to, err have some skill? :D but for now just be happy that you're posting in the same thread as me :D :D :D there's my 2 cents - even tho 1c coins expired ages down here :confused:


Yeah, you are a great scripter. And congrats on your scripting cup ;) I'm just glad to be in the presence of yours :p

It just makes my code look so noobish using FindColorTolerance because thats what you learn on your first tutorial :p

Still need some help on that for to do thing as said on the post above RKs.

shaunthasheep

2007-05-06 19:15:41

in:

for i := 1 to 50 do
writeln(inttostr(i));


or


for i := 1 to 50 do
begin
writeln(inttostr(i));
end;

the for statement automatically adds 1 to i each loop


=======================================

for i := 1 to 50 do
writeln(inttostr(i));

is the same as saying

i := 0
repeat
i := i + 1
Writeln(inttostr(i));
until(i = 50)

bullzeye95

2007-05-06 19:18:29

Ok here's how for loops work. Oh and you still have to declare the integer you're using. I forgot =S. If you have
For I:= 1 to 5 do
begin
writeln(IntToStr(I));
end;
It would increase I by 1 each time, starting at 1, until it reached 5. So in the debug box, it would look like
1
2
3
4
5

So basically, it would do something 5 times. Or if you had it like
For I:= 1 to 10 do
begin
Writeln(IntToStr(I));
end;
The debug box would look like
1
2
3
4
5
6
7
8
9
10


Understand now? :)

JAD

2007-05-06 19:29:16

I knew that about the variable :p I'm not that much of a noob. Thanks for explaining well though! I have a question for FindFastRandoms though. If you explain to me what this does:



function FindFastRandoms: Boolean; //By WT-Fakawi.
var
i: Integer;
begin
for i := 1 to 8 do
begin
case I of
1: if FindDead then
Result := True;
2: if FindMod then
Result := True;
3: if FindMime then
Result := True;
4: if FindMaze then
Result := True;
5: if FindQuiz then
Result := True;
6: if FindDemon then
Result := True;
7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;
7: begin
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Logout;
Exit;
end;
end;
8: RC;
end;
wait(1);
end;
end;


Then I'll get it :D Would that repeat looking for the randoms 8 times? And if the Result := True, it doesn't say to do something if it results true right? I know I'm probably sounding like I'm completely new to scripting right now lol :p

Thanks for helping though.

Edit: Wait, rs monkey, I get the repeat thing now (Only read bullzeye's thing at first) but about the Result := True thing and not doing anything, can somebody explain that?

And I still don't get why fakawi would make his randoms repeat 8 times in a row..

Ejjman

2007-05-06 20:13:06

I dunno why they put Result := True, that's wierd. But look

for I := 1 to 8 do
begin
case I of
1: writeln('1');
2: writeln('2');
//ETC
end;
end;

Ok so this has the same thing as above, its going through the begin..end as I being 1 2 3 4 5 6 7 8. So what it does if I is 1 then it will write 1. Then thats it in the case so it ends, then ends the main begin loop of the for statement, and switches the I from a 1 to a two. Then, it goes and writes a 2 because the I is now two. Understand? :)

JAD

2007-05-06 20:16:14

From: Ejjman1
I dunno why they put Result := True, that's wierd. But look

for I := 1 to 8 do
begin
case I of
1: writeln('1');
2: writeln('2');
//ETC
end;
end;

Ok so this has the same thing as above, its going through the begin..end as I being 1 2 3 4 5 6 7 8. So what it does if I is 1 then it will write 1. Then thats it in the case so it ends, then ends the main begin loop of the for statement, and switches the I from a 1 to a two. Then, it goes and writes a 2 because the I is now two. Understand? :)


Yeah I do thanks ejj :D Think I get it now!

Edit: Yeah, I used it 3 times in my new script already :p very helpful.

Ejjman

2007-05-06 20:22:25

Yes.

Just be careful you don't do this

for I := 0 to 8 do
blahb
blahb

You need the begin and end there. Just so'z ya know!

Boreas

2007-05-06 20:26:53

function FindFastRandoms: Boolean; //By WT-Fakawi.
var
i: Integer;
begin
for i := 1 to 9 do
begin
case I of
1: if FindDead then
Result := True;
2: if FindMod then
Result := True;
3: if FindMime then
Result := True;
4: if FindMaze then
Result := True;
5: if FindQuiz then
Result := True;
6: if FindDemon then
Result := True;
7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;
8: begin
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Logout;
Exit;
end;
end;
9: RC;
end;
wait(1);
end;
end;
=
function FindFastRandoms: Boolean; //By WT-Fakawi.
begin
wait(1);
if FindDead then
Result := True;
wait(1);
if FindMod then
Result := True;
wait(1);
if FindMime then
Result := True;
wait(1);
if FindMaze then
Result := True;
wait(1);
if FindQuiz then
Result := True;
wait(1);
if FindDemon then
Result := True;
wait(1);
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
wait(1);
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Logout;
Exit;
end;
wait(1);
RC;
wait(1);
end;

omgh4x0rz

2007-05-06 22:05:04

From: Ejjman1
I dunno why they put Result := True, that's wierd.


…because it's a boolean function that needs to return true or false, so you can do if(FindFastRandoms) then

or am I missing something that makes this more confusing?

rkroxpunk

2007-05-06 23:23:27

From: JAD
Yeah, you are a great scripter. And congrats on your scripting cup ;) I'm just glad to be in the presence of yours :p

It just makes my code look so noobish using FindColorTolerance because thats what you learn on your first tutorial :p

Still need some help on that for to do thing as said on the post above RKs.


Hey we all know u bribed the admins for it! :fiery:
:rolleyes:

Bam Bam

2007-05-06 23:26:54

From: omgh4x0rz
…because it's a boolean function that needs to return true or false, so you can do if(FindFastRandoms) then

or am I missing something that makes this more confusing?


Its the boolean value of the function which tells you if it found a random or not…

JAD

2007-05-07 00:28:38

From: Bam Bam
Its the boolean value of the function which tells you if it found a random or not…


What confuses me is if(FindMod) then result := True would just result true if it found a mod. If FindMod handles a mod by logging out then, and same with the other things in there then it would make more sense. I thought it was just looking for these things, not handling and resulting true if found.

Anyways thanks for all the help guys! I LOVE the for to do statements almost as much as I liked cases when I first learned them :p

nielsie95

2007-05-07 05:01:04

FindMod handles the mod by logging out and in. Same for all the other things: FindTalk handles all talking randoms.
You can use the boolean result for example chopping or fishing. If you are fishing and you get a random you stop fishing. So I use it to start fishing/chopping again:


if ClickTree then
begin
repeat
//Procedures
if FindFastRandoms then Break;
until TreeGone
end;

omgh4x0rz

2007-05-07 06:33:08

From: Bam Bam
Its the boolean value of the function which tells you if it found a random or not…


duh…I know that, and thats basically what I said.

Ejjman and JAD said they didn't know why there was a result:=true there, and I'm wondering what I'm missing because it seems pretty simple why you need result:=true in a function that needs to return either true or false.

Starblaster100

2007-05-07 08:06:47

FindRandoms is a bit confusing like that really.

How it works is, if a random is found in FindRandoms, the boolean results true. This is because it allows more flexibility in the script.


If (FindRandoms) then
PlaySound('');

For example.

However, the procedures inside FindRandoms, will react to each individual random event there.

So if FindMod result := True then it will log out for 1 minute and the log back in, if FindTalk := true then it will talk to the random event etc etc.

As for being a good scripter (and i hope im counted in that list!), practise makes perfect. If you don't know how something works, make a mini script using it - just something simple - so you can get used to using it, and then you can incorporate it into the bigger scripts and RS scripts

JAD

2007-05-07 09:09:58

From: Starblaster100
FindRandoms is a bit confusing like that really.

How it works is, if a random is found in FindRandoms, the boolean results true. This is because it allows more flexibility in the script.


If (FindRandoms) then
PlaySound('');

For example.

However, the procedures inside FindRandoms, will react to each individual random event there.

So if FindMod result := True then it will log out for 1 minute and the log back in, if FindTalk := true then it will talk to the random event etc etc.

As for being a good scripter (and i hope im counted in that list!), practise makes perfect. If you don't know how something works, make a mini script using it - just something simple - so you can get used to using it, and then you can incorporate it into the bigger scripts and RS scripts



Lol.. Never thought to count you in the list of good scripters star :p (j/k) Your awesome!

@Everybody else, I get the Result := True thing, and why/how its used. I already got all that before :p Its just that things like FindMod sound like it just looks for the mod doesn't it? Because I thought it just looked for the mod, and then the result = true if the script found a mod and thats it.

So I get booleans/functions and how there used :p I have since week 1 of scripting. Thanks for all the help though, and I'll use your advise star thanks.

Mjordan

2007-05-07 20:42:20

Ah ok I get the FindRandoms thing now. I always thought it just resulted back True or False, never knew it handled them too. But now that I think about it, it would be stupid for it not to, because if it didn't handle them then you would have to do something with them all separately.

Ejjman

2007-05-07 22:06:27

Ya'll know Functions can work like thisw…ritte??



function Random : boolean; //Find and solve thingy
begin
if(FindColor(200, 300) = 3034458)then
begin
Result := True;
SolveTheRandom;
end;
end;

So ya, like, ClickToContinue (which I've been obsessed with lately), it findsi t, results true, then solves! :) So ya you don't neecd like if(FindNormalRandoms)then SolveThemSomehowMysteriously…;

lol

And SB is muy osdjopsdh at scripting lol

Wanted

2007-05-09 18:07:35

If you want to become an advanced scripter like the Developers, Wizzup? Fawaki Starblaster Lorax Sumilion ect…. then you need to learn more about SCAR's parent language. Find a good tutorial on pascal and try learning some of the more key words like to down do try except finally round while

Once you learn more into the parent language (Pascal) then you start studying how it's applied in SCAR by trying to understand scripts like PowerSkills, Wizzups?'s ess minner, Goblin Scheduler ect…


Search around google for a Pascal Tutorial.

Infantry001

2007-05-09 18:16:31

And most of them have a better understanding of math and how loops and structures work, even before they test them. Its like they know waht the script will do before they even test it.