SRL Archive - OSR Help

Counting Items In Bank


Le_don

2013-08-08 20:54:52

Hi guys, does anybody know how to get this to work?

procedure CheckBank;
var
x, y: Integer;
BankPoint: Tpoint; //What the.. what is this SRL?
BankIndex: Integer; //Three functions needed to count bank items?

begin

If FindDTM(VTeleTab, x, y, 2, 2, 515, 335) then begin SMART_DrawBox(intToBox(x-18, y-18, x+18, y+18)); BankPoint := MSTPointToBankPoint(Point(x, y)); BankIndex := BankPointToBankIndex(point(BankPoint)); wait(300); end else Writeln('Did not find Tele Tab');
end;

rj

2013-08-08 21:14:47

Ehh I'm not sure the answer to your problem but I would like to throw this out there, you should attempt to make the code readable -.-


procedure CheckBank;
var
x, y: Integer;
BankPoint: Tpoint;
BankIndex: Integer;
begin
if FindDTM(VTeleTab, x, y, 2, 2, 515, 335) then
begin
SMART_DrawBox(intToBox(x - 18, y - 18, x + 18, y + 18));
BankPoint := MSTPointToBankPoint(Point(x, y));
BankIndex := BankPointToBankIndex(point(BankPoint));
wait(300);
end
else
Writeln('Did not find Tele Tab');
end;

Why not look in a static spot? Unless the teletab is going to randomly teleport around your bank interface, you shouldn't have any problems assuming you only look for the dtm if the bank is open

Le_don

2013-08-08 21:27:21

From: Officer Barbrady
Ehh I'm not sure the answer to your problem but I would like to throw this out there, you should attempt to make the code readable -.-


procedure CheckBank;
var
x, y: Integer;
BankPoint: Tpoint;
BankIndex: Integer;
begin
if FindDTM(VTeleTab, x, y, 2, 2, 515, 335) then
begin
SMART_DrawBox(intToBox(x - 18, y - 18, x + 18, y + 18));
BankPoint := MSTPointToBankPoint(Point(x, y));
BankIndex := BankPointToBankIndex(point(BankPoint));
wait(300);
end
else
Writeln('Did not find Tele Tab');
end;

Why not look in a static spot? Unless the teletab is going to randomly teleport around your bank interface, you shouldn't have any problems assuming you only look for the dtm if the bank is open

Barbrady, This means we can find the tab wherever whoever is using it has put it, without restricting it to one place.

Thanks, I'll test soon and + rep if works. And failsafes will be added soon, I've just been running the procedure (which has more than this) with it open for now.

rj

2013-08-08 21:30:49

From: Le_don
Barbrady, This means we can find the tab wherever whoever is using it has put it, without restricting it to one place.

Thanks, I'll test soon and + rep if works. And failsafes will be added soon..


Meh just tell the user to put it in a spot no point in over complicating it :s if they can't do that then they don't deserve to run a script :D

Le_don

2013-08-08 21:33:31

From: Officer Barbrady
Meh just tell the user to put it in a spot no point in over complicating it :s if they can't do that then they don't deserve to run a script :D


This stuff is needed for counting too, so I'll be using it to count ores.. We'll end up with 20 places for different things. Bit complex.

rj

2013-08-08 21:36:59

From: Le_don
This stuff is needed for counting too, so I'll be using it to count ores.. We'll end up with 20 places for different things. Bit complex.


You could always do:

GetAmountBox(Bounds:tBox);

Le_don

2013-08-08 21:57:35

From: Officer Barbrady
You could always do:

GetAmountBox(Bounds:tBox);


Perhaps, just realized you only formatted that code :'(

masterBB

2013-08-09 05:19:02

procedure CheckBank;
var
//x and y coordinates from the dtm.
x, y: Integer;

//the x an y coordinates as a Point relative to the bankscreen((x=0, y=0) is the upper left from the bankscreen
BankPoint: Tpoint;

//the index of the bankspot. Basically every bankspot has gotten a number, this number is the bankspot.
BankIndex: Integer;
begin

//Searches for the DTM and saves the coordinates it found the DTM in x and y.
if FindDTM(VTeleTab, x, y, 2, 2, 515, 335) then
begin

//Draws a square surrounding x an y so you can see what the script found. (for debugging)
SMART_DrawBox(intToBox(x - 18, y - 18, x + 18, y + 18));

//It takes the x and y coordinates and returns the coordinate relative to the bankscreen
BankPoint := MSTPointToBankPoint(Point(x, y));

//Gets the bankspot of the item, based on the relative coordinates.
BankIndex := BankPointToBankIndex(BankPoint); //removed point(x)
wait(300);

end else //if it couldn't find the DTM
Writeln('Did not find Tele Tab');
end;

Le_don

2013-08-09 07:12:18

From: masterBB
procedure CheckBank;
var
//x and y coordinates from the dtm.
x, y: Integer;

//the x an y coordinates as a Point relative to the bankscreen((x=0, y=0) is the upper left from the bankscreen
BankPoint: Tpoint;

//the index of the bankspot. Basically every bankspot has gotten a number, this number is the bankspot.
BankIndex: Integer;
begin

//Searches for the DTM and saves the coordinates it found the DTM in x and y.
if FindDTM(VTeleTab, x, y, 2, 2, 515, 335) then
begin

//Draws a square surrounding x an y so you can see what the script found. (for debugging)
SMART_DrawBox(intToBox(x - 18, y - 18, x + 18, y + 18));

//It takes the x and y coordinates and returns the coordinate relative to the bankscreen
BankPoint := MSTPointToBankPoint(Point(x, y));

//Gets the bankspot of the item, based on the relative coordinates.
BankIndex := BankPointToBankIndex(BankPoint); //removed point(x)
wait(300);

end else //if it couldn't find the DTM
Writeln('Did not find Tele Tab');
end;


Thanks a ton!