SRL Archive - OSR Help

Bank Slot Conversion


Macros

2008-12-05 17:47:27

Does anyone know a good way to convert a bank slot listed in (column, row) format, to a bank index? (spot in bank) I know that you could use BankPointToBankIndex(), but the input there isn't in (column, row) format.

Ultimately I want to convert a (column, row) to a Tbox; I plan to use BankIndexToMSBox(), after I can convert to a bank index. I know you could probably move the mouse to a bank slot, (using (column, row)), and then get the Tpoint etc, but that's not efficient enough for me >.<

EvilChicken!

2008-12-05 20:15:29

{*******************************************************************************
function BankPointToBankIndex(P: TPoint): Integer;
by: Wizzup?
Description: Converts a Bank Point (Row,Col) to Bank Index (spot in bank).
(0, 0) = 1
*******************************************************************************}


{*******************************************************************************
function BankIndexToBankPoint(ind: Integer): TPoint;
by: Wizzup
Description: Converts the Bank Index (spot in bank) to a Bank Point (Row,Col).
1 = (0, 0)
*******************************************************************************}

{*******************************************************************************
Function BankIndexToMSPoint(Index: Integer): TPoint;
by: Wizzup?
Description: Converts the Bank Index (spot in bank) to a Mainscreen TPoint of
the Index. (Top Left)
*******************************************************************************}

{*******************************************************************************
function BankIndexToMSBox(ind:Integer): TBox;
by: Wizzup
Description: Converts the Bank Index (spot in bank) to a Mainscreen TBox of
the Index.
*******************************************************************************}


You mean one of these?

Take a look in the bank.scar include, found in the 'misc' folder in SCAR, it might be helpful for you. ;)

Macros

2008-12-05 21:06:40

Yea I was looking at those for a while, but I don't think any of them would work for the exact purpose I want; because none of them have the ability to receive (column,row) input. I could maybe use one of them by changing around my procedure, if there's nothing else available, (or make my own function).

senrath

2008-12-05 21:22:50

Any reason you want (column,row) format? I mean, the first one listed takes it in (row,column) format. Wouldn't that work?

A G E N T

2008-12-05 23:52:17

I think:

spot = row * 4 + column - 4

ZephyrsFury

2008-12-06 09:53:44

Use BankPointToBankIndex (the first function that EvilChicken posted). The parameter is a TPoint with the row as x and the column and y:


Index := BankPointToBankIndex(Point(Row, Column));

Macros

2008-12-06 10:04:54

Ohh, I was unaware of the input format, Point(Row, Column), I always thought that those functions accepted a one-number input. Thanks!

mrpickle

2010-07-02 12:52:09

Not Gravedig cuz I got similar question. :P
Can someene elaborate on

index = MSTPointToBankPoint(Point(x,y));


What do we declare index as?


program New;
{.include srl/srl.scar}


var
TPA : TPointArray;

begin
If(FindBitmap(bitmap,x,y))then
begin
TPA ?? -= MSTPointToBankPoint(Point??(x,y));
Mouse(TPA... ???)
End;
End.

Frement

2010-07-02 17:28:46

Index is Integer.

Usage:
program new;
{$I SRL/SRL.scar}

var MSTP: TPoint;

begin
SetupSRL;
if( FindBitmap(bitmap,x,y)) then begin
MSTP := MSTPointToBankPoint(Point(x,y));
Mouse(MSTP.X, MSTP.Y, 4, 4, True);
end;
end.

mrpickle

2010-07-02 19:55:13

Thanks frement :)

Frement

2010-07-02 20:05:54

No problem, stuff like this can be figured out by looking at the return values of the functions.