shaunthasheep
2007-06-21 10:19:29
These functions will make banking easier! No more Deposit(2, 28, 2) blah because you don't want to deposit your pickaxe, now here is a better way!!!!
With DepositAllButThis & DepositAllButThese, you can make depositing your stuff in the bank perfect and all in one line!
Usages:
DepositAllButThis(yourbmp);
DepositAllButThese([array, of, your, bmps]);
EDIT: BTW, Inventorycount checks a non existing inventory column, see function InventoryCount, line 228 in inventory.scar, line is: for i := 0 to 4 do (0, 1, 2, 3, 4)<-THATS 5 COLUMNS, Needs to be changed too for i := 0 to 3
EDIT: scroll down for Bmp Tolerance & DTM version
With DepositAllButThis & DepositAllButThese, you can make depositing your stuff in the bank perfect and all in one line!
Usages:
DepositAllButThis(yourbmp);
DepositAllButThese([array, of, your, bmps]);
program DepositAllBut;
{.include SRL/SRL.scar}
var
theitem, theitem2, theitem3 : integer;
procedure LoadItemBmp;
begin
//currentely a bucket
theitem := BitmapFromString(6, 11, 'z78DA7DCF490E03310804C02F0DD02' +
'C3E7AFDFF9362052B9A2CCAA50ED0803042A362A9617D78EFFECD' +
'688192A1492506095F532ACF97CA7115EFA6527D596C5983FAB7C' +
'156A587DB9275DC59D07138C06FF5ACA4CB0D48BDB9F85B252DE2' +
'014DCF9EEC96B87CFD30AFE4AC7ADBB3FB831D1F41286585A0056' +
'CC8CCE4D91F3EE0D9AD1C8A9E5FDF2F9ECC734F4538E603072157' +
'05');
//currentely tin
theitem2 := BitmapFromString(5, 4, '8E84849086868D838389807F857C7C9' +
'28888948A8A9086868D8383000001968C8B988D8D928888000001' +
'211E1E9A8F8E9B91900000012523233E3939');
//currentely copper
theitem3 := BitmapFromString(4, 5, 'E1833AE1833ADC8039D87D37E5853CE' +
'8863CE3833ADF813AEC893EEC893EE8863C000001F18D44F18D44' +
'0000013A210EF29453000001000001472812');
end;
{*********************************************************************
function ExistsInIntArray(number : integer; intarray : Array of integer) : boolean;
By: The_Rs_Monkey
Checks to see if a number exists in an array of integer.
*********************************************************************}
function ExistsInIntArray(number : integer; intarray : Array of integer) : boolean;
var
e : integer;
begin
for e := 0 to GetArrayLength(intarray) - 1 do
begin
if intarray[e] = number then
begin
Result := True;
Exit;
end;
end;
end;
{*********************************************************************
procedure DepositAllButThis(item : integer);
By: The_Rs_Monkey
Deposits everything in the inventory except an item (represents by a bmp);
*********************************************************************}
procedure DepositAllButThis(item : integer);
var
Spots : Array Of Integer;
e, i, Mx, My : integer;
begin
GameTab(4);
for e := 0 to 6 do
begin
for i := 0 to 3 do
begin
Mx := (561 + (i * 43));
My := (208 + (e * 37));
if (FindBitmapIn(item, x, y, Mx, My, Mx + 40, My + 35)) then
begin
SetArrayLength(Spots, GetArrayLength(Spots) + 1);
Spots[GetArrayLength(Spots) - 1] := e * 4 + i + 1;
end;
end;
end;
for i := 1 to 28 do
begin
if Not ExistsInIntArray(i, Spots) then
if ExistsItem(i) then
Deposit(i, i, 2);
end;
end;
{*********************************************************************
procedure DepositAllButThese(item : array of integer);
By: The_Rs_Monkey
Usage: DepositAllButThese([bmp1, bmp2, bmp3, bmp4]);
Deposits everything in the inventory except these item (represents by an array of bmp);
*********************************************************************}
procedure DepositAllButThese(item : array of integer);
var
Spots : Array Of Integer;
e, i, q, Mx, My : integer;
begin
GameTab(4);
if GetArrayLength(item) = 0 then Exit;
for e := 0 to 6 do
begin
for i := 0 to 3 do
begin
Mx := (561 + (i * 43));
My := (208 + (e * 37));
for q := 0 to GetArrayLength(item) - 1 do
begin
if (FindBitmapIn(item[q], x, y, Mx, My, Mx + 40, My + 35)) then
begin
SetArrayLength(Spots, GetArrayLength(Spots) + 1);
Spots[GetArrayLength(Spots) - 1] := e * 4 + i + 1;
Break;
end;
end;
end;
end;
for i := 1 to 28 do
begin
if Not ExistsInIntArray(i, Spots) then
if ExistsItem(i) then
Deposit(i, i, 2);
end;
end;
begin
ClearDebug;
SetUpSrl;
ActivateClient;
Wait(2000);
LoadItemBmp;
//DepositAllButThis(theitem);
DepositAllButThese([theitem, theitem2, theitem3]);
end.EDIT: BTW, Inventorycount checks a non existing inventory column, see function InventoryCount, line 228 in inventory.scar, line is: for i := 0 to 4 do (0, 1, 2, 3, 4)<-THATS 5 COLUMNS, Needs to be changed too for i := 0 to 3
EDIT: scroll down for Bmp Tolerance & DTM version