SRL Archive - Help and Support

My First Ever Script


weaselforce

2006-03-26 00:36:05

kk well a few days ago i decided i would learn a little more about scar scripting and make my own script. Its a big perspective change from just leeching scrips all the time lol. so anyways, i didnt get to finish it. well i kinda messed it up by not using srl setup from the beginning due to me not understanding properly what was to be done with SRL.

I attempted this project to basically practice designing scripts and learn alot. Some of my code is probably really bad or confusing, but if you have any suggestions, comments, changes, I would GREATLY appreciate it.

I Couldnt finish it because scar lags reallly bad when i use this script, i have no reason why…anyone know? so the first few procedures work fine cause i could test them, but it went too slow afterward to continue testing. Heres my vial filler script ( i chose a vial filler cause i had 300 empty vials and i thought it might be a nice easy first script )

procedures dont have wait times and main loop is incomplete

  

// ***** Weasel's First Script ***** \\
// \\
// Super Neato Awesome Vial Filler! \\
{-------------------------------------------}
// Special thanks to SRL Team for making this possible :)
// And thanks to SDcit for answering my many noobie questions :)


program VialFiller;

{.include SRL/SRL.scar}



const
//Set the Colors here\\
watercolour = 0; //fountain Color
filledvialcolor = 11964297;// What a filled vial looks like
emptyvials = 250;//how many vials you have
RoadColour = 0;

var Watersymbol,Rcolor,TotalDone,VialsToDo:integer;

// ***Arrange Ingame*** \\
procedure arrange;
Begin
SetupSrl;
Face('N');
SetRun(true);
ChatsOff;
wait(100);
end;

// ***loading the water symbol bitmap*** \\
procedure LoadBitmaps;

var Watersymbol:integer;

begin
watersymbol:= BitmapFromString(7, 11, 'AAC4B78BA3A5B3C2E16' +
'E7AA2717D97BFCAD0AEBBA9BCD5D1B7CDD87786AF596595919BBE' +
'939FADBAC6BC9BB2C0A5BAD53E4D86545F9F858FC2ABB6D4A6B1B' +
'79EB5D57287B46A78C3404B9D97A0E5BDC7F8A1ACC29CB2E48093' +
'D54653B1424BB04950A8A8B1F4BAC3EA6B80BF4659A5B2BFFF4B5' +
'5C43F47A98089D6A1ABDC6E85C8A7BAFF9FABFF6771E4161E831C' +
'2574BCC8FC4860A04F65B1AFBDFF4753C3283293333F8B7D8BBA6' +
'17CB1384F925363C2323FA52733892E3C7D8696BA86A3CB395288' +
'1F318312227A3848936676AA9EAFC9A6C4DE93AFD78EA2E7889AE' +
'68597D592A4CCA5B8C6');
end;

procedure Watersymboloff;

begin
FreeBitmap(watersymbol)
end;

// ***Settin Up Colors and such** \\
procedure startup;
var TotalDone:integer;
begin
If LoggedIn then
begin
Rcolor:=RoadColour
TotalDone := 0
VialsToDo := emptyvials;
end
else
begin
writeln('didnt sense you as being logged in')
writeln('Please log in and try again')
end;
end;

// ***walkin twords fountain***
procedure walktofountain;
var waterx,watery:integer;
begin
repeat
RoadWalk(Rcolor,'NW');
until (FindBitmap(watersymbol,waterx,watery));
begin
MoveMouseSmooth(waterx,watery);
clickMouse(waterx,watery,true);
Wait(random(30)+40);
clickMouse(waterx,watery,true);
end;
end;

//***Check Colors and start Vial Filling***\\
procedure StartAndColorCheck;
begin
if FindMSColorTol(x,y,watercolour,5)then
begin
writeln('colors worked fine,beginning loop');
end
else
begin
writeln('Couldnt Locate the Fountain or Fountain Colors');
writeln('please make sure fountain was insight');
writeln('and or please check your colors');
Logout;
end;
end;

//***Fill Vials***\\
procedure FillVials;
begin
UseItem(28);
ClickMSColorTol(watercolor,5,true);
wait(random (100)+1000);
if FindItemColorTol(filledvialcolor,5) then
begin
end
else
begin
writeln('vial color wrong, either set it yourself')
writeln('you can disable this whole procedure if you like')
writeln('or else my..[Shock] script messed up! [/Shock]')
logout;
end;
end;

//***Return To Bank And Deposit All***\\
procedure ReturnToBankAndDeposit;
var Gettime:integer;
begin
Gettime:= GetSystemTime;
repeat
RoadWalk(Rcolor,'SE');
until(FindMMColor(x,y,bankcolor));
if(GetSystemTime-Gettime >= 4000)then
Begin
writeln('got lost heading to bank')
writeln('Autostopped to avoid you ending in alkahrid')
writeln('Please restart script, make sure all goes well')
writeln('If failed again, script probably broken or bank crowded')
CloseWindow;
Logout;
end
else
begin
FindBank('veb');
if Bankscreen then
begin
DepositAll;
TotalDone := +28
VialsToDo := -28
end
else
writeln('didnt let you access bank')
writeln('Please check the pin constant')
writeln('please restart script')
writeln('bank may be too crowded...')
writeln('if it still wont work probably busted')
end;
end;


//***Withdraw from bank***\\
procedure Withdrawfrombank;
begin
OpenBank;

if Bankscreen then
if TotalDone < emptyvials-28 then
begin
FixBank;
withdraw(1,1,0);
end
else
begin
withdraw(1,1,VialsToDo-1);
writeln('doing your last set of vials, less than 28')
end
else
begin
writeln('didnt let you access bank')
writeln('Please check the pin constant')
writeln('bank may be too crowded')
writeln('please restart script')
writeln('if it still wont work probably busted')
CloseWindow;
logout;
end;
end;

//***Uses Srl Randoms***\\
procedure randoms;
begin
FindNormalRandoms;
wait(random (50)+50)
FindMiscRandoms;
end;

//***mainloop***\\
Begin
startup;
arrange;
withdrawfrombank;
randoms;
loadbitmaps;
//walktofountain;
//startandcolorcheck;
//randoms;
//watersymboloff;
//fillvials;
//ReturnToBankAndDeposit;
//randoms;
end.

Pwnd

2006-03-26 02:05:19

It might lag really bad because of this: you're using local variables and the same variables as global variables.

This is what I mean:

procedure blah;
var
ddld: integer;
That is a local variable.

program lskdfjls;
var
ldkjfd: integer;

procedure blah;
begin
end;
That is a global variable.

Global variables are on the outside of the procedures and local is on the inside of the procedures.
You duplicated some local variables as global variables. I'd say make them global because they spread across multiple procedures.

// ***** Weasel's First Script ***** \\
// \\
// Super Neato Awesome Vial Filler! \\
{-------------------------------------------}
// Special thanks to SRL Team for making this possible
// And thanks to SDcit for answering my many noobie questions


program VialFiller;

{.include SRL/SRL.scar}



const
//Set the Colors here\\
watercolour = 0; //fountain Color
filledvialcolor = 11964297;// What a filled vial looks like
emptyvials = 250;//how many vials you have
RoadColour = 0;

var
Watersymbol, Rcolor, TotalDone, VialsToDo: integer;

// ***Arrange Ingame*** \\
procedure arrange;
Begin
SetupSrl;
Face('N');
SetRun(true);
ChatsOff;
wait(100);
end;

// ***loading the water symbol bitmap*** \\
procedure LoadBitmaps;
begin
watersymbol:= BitmapFromString(7, 11, 'AAC4B78BA3A5B3C2E16' +
'E7AA2717D97BFCAD0AEBBA9BCD5D1B7CDD87786AF59659591 9BBE' +
'939FADBAC6BC9BB2C0A5BAD53E4D86545F9F858FC2ABB6D4A 6B1B' +
'79EB5D57287B46A78C3404B9D97A0E5BDC7F8A1ACC29CB2E4 8093' +
'D54653B1424BB04950A8A8B1F4BAC3EA6B80BF4659A5B2BFF F4B5' +
'5C43F47A98089D6A1ABDC6E85C8A7BAFF9FABFF6771E4161E 831C' +
'2574BCC8FC4860A04F65B1AFBDFF4753C3283293333F8B7D8 BBA6' +
'17CB1384F925363C2323FA52733892E3C7D8696BA86A3CB39 5288' +
'1F318312227A3848936676AA9EAFC9A6C4DE93AFD78EA2E78 89AE' +
'68597D592A4CCA5B8C6');
end;

procedure Watersymboloff;
begin
FreeBitmap(watersymbol);
end;

// ***Settin Up Colors and such** \\
procedure startup;
begin
If LoggedIn then
begin
Rcolor:=RoadColour
TotalDone := 0
VialsToDo := emptyvials;
end else
begin
writeln('didnt sense you as being logged in')
writeln('Please log in and try again')
end;
end;

// ***walkin twords fountain***
procedure walktofountain;
var
waterx,watery:integer;
begin
repeat
RoadWalk(Rcolor,'NW');
until (FindBitmap(watersymbol,waterx,watery));
begin
MoveMouseSmooth(waterx,watery);
clickMouse(waterx,watery,true);
Wait(random(30)+40);
clickMouse(waterx,watery,true);
end;
end;

//***Check Colors and start Vial Filling***\\
procedure StartAndColorCheck;
begin
if FindMSColorTol(x,y,watercolour,5)then
begin
writeln('colors worked fine,beginning loop');
end else
begin
writeln('Couldnt Locate the Fountain or Fountain Colors');
writeln('please make sure fountain was insight');
writeln('and or please check your colors');
Logout;
end;
end;

//***Fill Vials***\\
procedure FillVials;
begin
UseItem(28);
ClickMSColorTol(watercolor,5,true);
wait(random (100)+1000);
if FindItemColorTol(filledvialcolor,5) then
begin
end else
begin
writeln('vial color wrong, either set it yourself')
writeln('you can disable this whole procedure if you like')
writeln('or else my..[Shock] script messed up! [/Shock]')
logout;
end;
end;

//***Return To Bank And Deposit All***\\
procedure ReturnToBankAndDeposit;
var
Gettime:integer;
begin
Gettime:= GetSystemTime;
repeat
RoadWalk(Rcolor,'SE');
until(FindMMColor(x,y,bankcolor));
if(GetSystemTime-Gettime >= 4000)then
Begin
writeln('got lost heading to bank')
writeln('Autostopped to avoid you ending in alkahrid')
writeln('Please restart script, make sure all goes well')
writeln('If failed again, script probably broken or bank crowded')
CloseWindow;
Logout;
end else
begin
FindBank('veb');
if Bankscreen then
begin
DepositAll;
TotalDone := +28
VialsToDo := -28
end else
writeln('didnt let you access bank')
writeln('Please check the pin constant')
writeln('please restart script')
writeln('bank may be too crowded...')
writeln('if it still wont work probably busted')
end;
end;


//***Withdraw from bank***\\
procedure Withdrawfrombank;
begin
OpenBank;

if Bankscreen then
if TotalDone < emptyvials-28 then
begin
FixBank;
withdraw(1,1,0);
end else
begin
withdraw(1,1,VialsToDo-1);
writeln('doing your last set of vials, less than 28')
end else
begin
writeln('didnt let you access bank')
writeln('Please check the pin constant')
writeln('bank may be too crowded')
writeln('please restart script')
writeln('if it still wont work probably busted')
CloseWindow;
logout;
end;
end;

//***Uses Srl Randoms***\\
procedure randoms;
begin
FindNormalRandoms;
wait(random (50)+50)
FindMiscRandoms;
end;

//***mainloop***\\
Begin
startup;
arrange;
withdrawfrombank;
randoms;
loadbitmaps;
//walktofountain;
//startandcolorcheck;
//randoms;
//watersymboloff;
//fillvials;
//ReturnToBankAndDeposit;
//randoms;
end.

weaselforce

2006-03-26 02:12:13

ok i understand, but just on a side note, are local variables faster than global? so if a variable is used only once shud i make it local? or is it just a better idea to make them all global. ive just seen alot of scripts that had local and global variables

XxKanexX

2006-03-26 03:14:21

Code tags next time, please…

 Script 


Without the spaces after "e".

weaselforce

2006-03-26 03:37:55

yea soz, i forgot the

Wizzup?

2006-03-26 06:06:46

Nice work and you could use FindSymbol,
FindSymbol('Symbol Here')

FindSymbol('water source')

It's in core\Symbol.scar

You also might want to set SymbolAccuracy

phantombmx

2006-03-26 11:59:29

you might wanna change those few lines that have movemousesmooth and clickmouse.. considering you are using SRL you might wanna use MMouse(x,y,randx,randy:integer) to move the mouse and CMouse(x,y,rx,ry:integer; left:boolean) to click.. way less detectable good job nonetheless!

weaselforce

2006-03-26 14:20:40

kk thanks, i'll look into that

Pwnd

2006-03-26 15:47:29

From: weaselforce
ok i understand, but just on a side note, are local variables faster than global? so if a variable is used only once shud i make it local? or is it just a better idea to make them all global. ive just seen alot of scripts that had local and global variables

Actually, I don't know if they're faster, but it makes your script a hell of a lot cleaner and you can track the variables easier. It is said that it is better to use local variables and it is part of the Script Standards.

You don't have to eliminate global variables completely, just try to use them as seldomnly as possibley.

I don't want to see

var
x, y: integer;
anywhere…. If I see that, I'll beat you and then clean your script.

XxKanexX

2006-03-26 20:28:08

SRL has it's own declared x and y variables.

Global:

var a, b: Integer;

begin
a:= 0;
b:= 0;
end.

Local:

Procedure GlobeTest;
var a, b: Integer;
begin
a:= 1;
b:= 1;
end;

Global are declared and can only be used within a procedure or function. They're extremely useful for avoiding duplicated identifiers :)

Bebe

2006-03-26 20:34:31

Kane, you switched global and local vars around :p

reread what you wrote…..

XxKanexX

2006-03-26 20:43:38

From: Bebemycat2
Kane, you switched global and local vars around :p

reread what you wrote…..

Arg, i did to. Thanx ;)

weaselforce

2006-03-26 21:24:40

lol your gona screw me up for life! and no i didnt use variable x,y in my script, i think that was just some random comment…

Pwnd

2006-03-26 23:29:19

Why the fuck does an include use x and y as global variables? :\

Sdcit

2006-03-26 23:40:58

so we dont have to declare them XD

XxKanexX

2006-03-27 02:45:55

From: Sdcit
so we dont have to declare them XD

Yep, it's really useful aswell. :)