SRL Archive - SRL Suggestions

GameTab.scar WearingItem


NCDS

2010-06-28 19:54:38


{*******************************************************************************
function WearingItem(i: Integer): Boolean;
By: RsN
Description: Results True if an item is equipped at equpiment slot defined by I.
*******************************************************************************}
function WearingItem(I: Integer): Boolean;
var
X, Y: Integer;
TP: TPoint;
begin
Result := false;
if (not InRange(I, 1, 11)) then
begin
srl_Warn('WearingItem', 'Equipment slot #' + IntToStr(I) + ' is not a valid equipment slot', warn_Warning);
Exit;
end;
if (GetCurrentTab <> tab_Equip) then
begin
GameTab(tab_Equip);
if GetCurrentTab <> tab_Equip then exit;
Wait(750 + Random(500));
end;
TP := EquipmentCoords(I);
Result := FindColor(X, Y, srl_outline_black, TP.x - 8, TP.y - 8, TP.x + 8, TP.y + 8);
end;
As you can see, the original code is pretty outdated as far as selecting the Gametab anyways.


function WearingItem(I: Integer): Boolean;
var
X, Y: Integer;
TP: TPoint;
begin
Result := false;
if (not InRange(I, 1, 11)) then
begin
srl_Warn('WearingItem', 'Equipment slot #' + IntToStr(I) + ' is not a valid equipment slot', warn_Warning);
Exit;
end;
if (not Gametab(tab_Equip)) then
Exit;
Wait(250 + Random(500));
TP := EquipmentCoords(I);
Result := FindColor(X, Y, srl_outline_black, TP.x - 8, TP.y - 8, TP.x + 8, TP.y + 8);
end;
I just cleaned up the tab selection is all.

Both work perfectly fine, the second one is obviously somewhat quicker though.

Coh3n

2010-06-28 20:17:30

Committed. :)