SRL Archive - OSR Help

CoordsToItem


P1ng

2012-08-05 03:15:29

So I'm having an issue with CoordsToItem in my alching script, I keep getting an error saying that the co-ordinates are out of bounds
** Warning in InvBox: Incorrect index: 0 **
Warning! You passed a wrong xs to a finder function: -1. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -1. That is below 0, thus out of bounds. Setting the value to 0 for now.

This is the procedure I am trying to use it in
procedure ClickItem;
var
x,y,T: Integer;
begin
Status('ClickItem');
if not LoggedIn then
NextPlayer(False);
if GameTab(Tab_Inv) then
begin
if ExistsItem(CoordsToItem(x,y)) then
begin
ClickMouse2(mouse_Left);
Inc(Alch);
WriteLn('Successfully clicked the item');
MarkTime(T);
repeat
Wait(RandomRange(20,40));
if FindDTM(Alchemy,x,y,MIX1,MIY1,MIX2,MIY2) or LvlInc then
Break;
until(TimeFromMark(T) > 8000);
end else
begin
WriteLn('Item not found @ClickItem');
NextPlayer(False);
end;
end else
WriteLn('Not in inventory @ClickItem');
end;

Currently running Simba 991 and SMART v7.2
So I developed a procedure to have a look at the InvBoxes, it seems that the SMART_DrawBoxEx function is drawing a square immediately above the correct invslot, but InvMouse is working appropriately.
But CoordsToItem is returning 0 for every mouse position in the inventory.

Try running this script and you will see what I mean.
program P1ngScript;
{$DEFINE SMART}
{$i SRL/SRL.Simba}
{$i SRL/SRL/Misc/SmartGraphics.Simba}

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := ''; // Username
Pass := ''; // Password
Active := True;
end;
end;

procedure SetupLogin;
begin
ClearDebug;
{$IFDEF SMART}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}

SetupSRL;
DeclarePlayers;
ActivateClient;
if not LoggedIn then
LoginPlayer;
end;
procedure DrawTheBox;
var
x,y,i: Integer;
Color: Array of Integer;
begin
Color := [clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow];
SMART_ClearCanvas;
for i := 0 to 27 do
begin
SMART_DrawBoxEx(False, False, InvBox(i + 1), Color[i]);
InvMouse(i + 1,mouse_Move);
Wait(RandomRange(800,1200));
WriteLn(CoordsToItem(x,y));
end;
end;

begin
SetupLogin;
DrawTheBox;
end.

riwu

2012-08-05 03:25:58

You didn't assign any integer value to ur x,y variables? You should call GetMousePos(x,y) to get the x,y coordinates first (after u move ur mouse there). Also you can just do 'for i:=1 to 28' instead of having to add 1 to i afterwards.

Brandon

2012-08-05 03:29:09

There is no I = 0 is what your error says:

for i := 1 to 28 do

P1ng

2012-08-05 03:29:36

LOL! Dammit -.- GetMousePos(x,y) has fixed all my troubles. Thanks mate :)

EDIT:
@Brandon - If you look at the invmouse and drawboxex functions i have i + 1 as where it moves the mouse and what it draws the box of.
EDIT2:
@Riwu - GetMousePos fixed it. And with the i := 1 to 28 because I only have 28 colours in the 'Color' array and it took the first colour as 0 I was recieving an out of range error with i := 1 to 28