SRL Archive - OSR Help

help finding objects with blacklist


Bonfield

2010-12-18 02:34:29

I am trying to search for clay in the bank, and what i want to do is store it in as a player integer to use later on, but the way i tried to do it must be wrong because it hovers the top left of the bankscreen/runescape client, the script never finds the clay and i can not figure ot why


function Find_Clay: Boolean;
var
i: Integer;
begin
for i := 1 to 40 do // the first 4 lines in the bank
writeln(inttostr(Get_Black_Count(i, SRL_OUTLINE_BLACK, True)));
if(Get_Black_Count(i, SRL_OUTLINE_BLACK, True) = CLAY_BLACKCOUNT) then
begin
Players[CurrentPlayer].Integers[CLAY_BANKSLOT] := i;
writeln('Player ' + IntToStr(CurrentPlayer) + ' has clay in bankslot '+ inttostr(Players[CurrentPlayer].Integers[CLAY_BANKSLOT]));
Exit;
end;
end;


{*******************************************************************************
function Withdraw_Clay: Boolean;
By: Bonfield
Description: Deposits soft clay to bank
*******************************************************************************}
function Withdraw_Clay: Boolean;
var
Max_Time: Integer;
Index: TPoint;
Bank_Slot: TBox;
begin
if (not LoggedIn) then Exit;
if (not In_Bank) then Exit;
Max_Time := GetSystemTime + (2 * 60 * 1000); // Max time of 2 minutes.
Open_Bank(WHICH_BANK);
while (not(Result)) and (GetTimeRunning < Max_Time) do
begin
if (Players[CurrentPlayer].Integers[CLAY_BANKSLOT] = 0) then
Find_Clay else
begin
writeln('lolz');
Index := BankIndexToBankPoint(Players[CurrentPlayer].Integers[CLAY_BANKSLOT]);
writeln('Index X is ' + IntToStr(Index.X));
writeln('Index Y is ' + IntToStr(Index.Y));

Bank_Slot := BankIndexToMSBox(Players[CurrentPlayer].Integers[CLAY_BANKSLOT]);
MouseBox(Bank_Slot.X1, Bank_Slot.Y1, Bank_Slot.X2, Bank_Slot.Y2, 3);

if WaitUpTextMulti(['Withdraw-1 c', 'w-1 Clay', 'lay'], 500) then
begin
Result := True;
Withdraw(Index.X, Index.Y, 0);
writeln('Withdrew Clay');
CloseBank;
Exit;
end else
Result := False;
writeln('Withdraw failed CountColor was correct but uptext wasnt');
end;
end;
end;

EDIT: sorry i didnt now there was a help section

KingKong

2010-12-18 02:54:40

Did you put the clay in the first bank slot? Because the first bank slot is 0 not one.

Edit: Is this using MSI?

Bonfield

2010-12-18 02:56:22

no it is in the second, i moved it aroundeg 2, 5, 7 spot to see if that changed anything but it didnt

KingKong

2010-12-18 02:58:17

Mind posting the function (Get_Black_Count(i, SRL_OUTLINE_BLACK, True))? maybe somethings wrong with that?

Bonfield

2010-12-18 03:05:55

no problems

function Get_Black_Count(Slot, Color: Integer; Bank: Boolean): Integer;
var
b: TBox;
begin
Result := 0;
if Bank then
b := BankIndexToMSBox(Slot)
else
b := InvBox(Slot);
Result := CountColor(Color, b.X1, b.Y1 + Y_MOD, b.X2, b.Y2);
end;

KingKong

2010-12-18 03:11:35

I think it has problems with finding items in bank, look at this thread:
http://villavu.com/forum/showthread.php?t=57813

starting from post 11

Edit: I think the number of black pixels changes everytime you add or remove any number of clay since it changes the number at top.

Bonfield

2010-12-18 04:17:57

im pretty sure SRL's constant for the black outline has changed i will look into it more and let you people know

EDIT: i have added 15 to the y1 part of my search to fix the problem ou mentioned, i can not take credit for that, it was boreas and without his tutorial/post a while back i wouldnt hve known about them

EDIT 2: i fixed the problem, it was because SRL's black outline was not correct, or i set up runescape wrong, but i also had to rewrite the function am making to withdraw it


function Withdraw_Clay: Boolean;
var
i, h,l, Max_Time, x, y: Integer;
Bank_Slot: TBox;
SlotsIn: array of Integer;
begin
if (not LoggedIn) then Exit;
if (not In_Bank) then Exit;
Max_Time := GetSystemTime + (2 * 60 * 1000); // Max time of 2 minutes.
Open_Bank(WHICH_BANK);
while (not(Result)) and (GetTimeRunning < Max_Time) do
begin
Count_Items(CLAY_BLACKCOUNT, 1, 50, SlotsIn)
OutputArray(SlotsIn, 'CLAY_BLACKCOUNT in Bank slots');
h:= High(SlotsIn);
l := Length(SlotsIn);
if (l > 0) then
begin
for i:=0 to h do
begin
Bank_Slot := BankIndexToMSBox(SlotsIn[i]);
MouseBox(Bank_Slot.X1, Bank_Slot.Y1, Bank_Slot.X2, Bank_Slot.Y2, 3);
wait(500);
if WaitUpTextMulti(['Withdraw-1 c', 'w-1 Clay', 'lay'], 1000) then
GetMousePos(x,y);
Mouse(x, y, 0, 0, false);
WaitOption('All', 1000);
Players[CurrentPlayer].Integers[CLAY_BANKSLOT] := SlotsIn[i];
writeln('Player ' + IntToStr(CurrentPlayer) + ' has clay in bankslot '+ inttostr(Players[CurrentPlayer].Integers[CLAY_BANKSLOT]));
exit;
end;
end else
writeln('SlotsIn Array = 0');
Result := False;
end;