SRL Archive - OSR Help

Complete noob needs help with simple script!


rjk1990

2012-04-14 21:04:42

Alright, so here goes. I'm throwing myself at the mercy of you guys here.
I didn't want to feel like a leecher so i attempted some tutorials on basic scripting, and although i feel like A LOT of it went over my head.. i managed to get the tree cutting script to work. I figured it'd be easy to apply that knowledge to a simple buying/banking script.

well it wasn't for me :P Really, even reading the tutorials i have no clue what i'm doing other then what i'm told, so this will probably look like a COMPLETE MESS to you guys. Just, tell me where i went wrong? xD

The idea was to have a simple script that finds the bank shop (at the lumbridge chest, I'm standing right next to it so no moving involved) buy "all" chocolate bars and bank them. I guess you can see what i had in mind but it doesnt quite translate :P


program new;
{$DEFINE SMART}
{$i srl/srl.simba}

Procedure DeclarePlayers;
Begin
Howmanyplayers :=1;
Numberofplayers(howmanyplayers);
CurrentPlayer :=0;

Players[0].name :='';
Players[0].pass :='';
Players[0].nick :='';
Players[0].pin :='';
Players[0].Active:=True;
End;

Procedure Startup;
begin
MakeCompass('N');
SetAngle(0);
Writeln('Setting the compass');
GameTab(Tab_Inv);
end;


procedure FindShop;
Var x,y: integer;
begin
if findObj(x,y, 'hest', 5793906, 10)then
begin
mouse(x,y, 2,1, false);
chooseoption('ood');
end;
end;

Procedure BuyFood;
var x, y: integer;
begin
if findObj(x,y, 'hoco', 1452102, 5)then
begin
mouse(x, y, 2, 1, false);
chooseoption('all') ;
end;
end;

Procedure BankChest;
var x, y: integer;
begin
if findobj(x, y, 'hest', 5793906, 10)then
begin
mouse(x, y, 2, 1, true)
If PinScreen then
InPin(Players[CurrentPlayer].Pin);
if findobj(x, y, 'eposit', 1854330, 5)then
mouse(x, y, 2, 1, true)
end;
end;


begin
SetupSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
Startup;
FindShop;
BuyFood;
Bankchest;
end.

So yeah, It gets about as far as opening the shop (if im lucky before completely failing to do anything worthwhile xD)

NKN

2012-04-14 21:42:02

Try not to use FindObj.
Maybe the color was off? You could try using AVA, check out Kyle Undefined's "Your First Script" to figure out how to use it, it's a lot more accurate.

Abu

2012-04-15 08:56:28

Ok first of all, I'm going to recommend as this is your first script, you should be using at least FindObjCustom rather than FindObject. It works exactly the same except for you can search for multiple uptext and most importantly multiple colors. It works like this:
 FindObjCustom(x, y, ['att', 'ack'], [123456, 345678], 5); 

Also, another flaw I noticed was that in your banking procedure I'm not sure exactly what you're doing with this line:
  If findobj(x, y, 'eposit', 1854330, 5)then
mouse(x, y, 2, 1, true)
Are you trying to click the Deposit All button on the Bankscreen? If so you can use a simple SRL function called DepositAll;

Also, I recommend you make DTMs to recognise the chocolate bar as a LOT of items have the same brown color, hence you'll end up having your mouse moving around in a spasm trying to find the right uptext. If you want to learn how to make DTMs you can find a handful of guides in the tutorial section.

rjk1990

2012-04-15 15:30:57

Thank you, yeah i was trying to go deposit with my limited knowledge, it seemed like it would have worked :D

Was everything else in the banking section ok? I'm not even sure i used "pinscreen" in the correct manner to be honest - again another one to read up on

I'll look at further guides. I tried a DTM tutorial that was meant to be "really simple" and the whole thing went over my head. Maybe i was just tired ^^

again thanks

rjk1990

2012-04-16 15:20:16

Okay, so i was following a tutorial, and started my hand at making the basics of the script entirely from memory:

program new;
{$i srl/srl.simba}



Procedure DeclarePlayers;
Begin
Howmanyplayers :=1;
Numberofplayers(howmanyplayers);
CurrentPlayer :=0;

Players[0].name :='';
Players[0].pass :='';
Players[0].nick :='';
Players[0].Active:=True;
End;



// ACA data
function treecolor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.14, 0.44);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 3491920, MSX1, MSY1, MSX2, MSY2, 2);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC, X, Y, Z);

if (X >= 5.69) and (X <= 6.82) and (Y >= 6.01) and (Y <= 7.18) and (Z >= 3.97) and (Z <= 4.78) then
begin
Result := arC;
Writeln('AutoColor = ' + IntToStr(arC));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;




//Finds the Tree, and clicks it
Function FindTree:Boolean;
var
x, y: Integer;
begin
FindNormalRandoms;
x:=MSCX ;
Y:=MSCY;
If findObjTPA(x, y, treecolor, 5, 1, 10, 50, 300, ['chop'])then
begin
Mouse(x, y, 2, 2, true);
end;
end;



begin
SetupSRL;
ActivateClient;
DeclarePlayers;
FindTree;
end.


Basically just wanted the script to find a tree and click. It finds the tree perfectly but never clicks, just hovering over each one before stopping. why?

Total

2012-04-16 15:25:10

You are missing an end; in your FindTree function. Put 1 more end;. You need to end case statements.

Abu

2012-04-16 15:25:44

You need one more end on your FindTree function :)

EDIT: Ninja'd by TotalKillz :(

Total

2012-04-16 15:27:02

Owned. :p

Abu

2012-04-16 15:29:35

Well did you fix his Standards?
program new;
{$i srl/srl.simba}

procedure DeclarePlayers;
begin
Howmanyplayers :=1;
Numberofplayers(howmanyplayers);
CurrentPlayer :=0;

Players[0].name :='';
Players[0].pass :='';
Players[0].nick :='';
Players[0].Active:=True;
end;



// ACA data

function TreeColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.08);
FindColorsSpiralTolerance(MSCX, MSCY, arP, 2374992, MSX1, MSY1, MSX2, MSY2, 7);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 2.81) and (X <= 8.83) and (Y >= 2.76) and (Y <= 8.55) and (Z >= 1.34) and (Z <= 3.79) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;


//Finds the Tree, and clicks it
function FindTree:Boolean;
var
x, y: Integer;
begin
FindNormalRandoms;
x:=MSCX ;
Y:=MSCY;
if findObjTPA(x, y, TreeColor, 5, 1, 15, 60, 600, ['cho']) then
begin
GetMousePos(x, y);
case random(2) of

0: mouse(x, y, 5, 5, true);

1: begin
mouse(x, y, 5, 5, false);
waitoption('hop', 600);
end;
end;
end;
end;


begin
SetupSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
FindTree;
end.

Ok so I made one mistake I can see, who cares :p

Total

2012-04-16 15:30:38

Oh snap. Brb making custom TPA object finding for his script. Jk lol.

Abu

2012-04-16 15:31:29

From: TotalKillz
Oh snap. Brb making custom TPA object finding for his script. Jk lol.


Lol at this rate we're gonna make him a flawless script :)

Total

2012-04-16 15:35:25

Wow lol. I'm looking at that code and realized I don't follow normal standards. o.O Never knew you indented if statements….brb tutorial section lmao.

rjk1990

2012-04-16 16:22:34

Lol, thanks. I missed the end; (didn't know about the case thing) Thanks for being helpful and not flaming me for silly mistakes.

Okay, so i got the script to find a tree perfectly and click it from memory even after logging in and out. I call that a win after one day xD

as to above poster, I'm entirely sure my standards are not correct due to completely messing up and deleting lines xD