SRL Archive - Jr. Member General Help and Discussion

Open grandexchange function


Thomas

2015-04-14 15:17:39

Hey,

What do you guys think about this GE open function;

function openGE(): boolean;
var
FailCount, x, y: integer;
begin
if not isLoggedIn() then
exit;
FailTimer.start();
repeat
if mainscreen.findObject(x, y, 3611949, 4, colorSetting(2, 0.7, 1.1), mainscreen.playerPoint, 50, 110, 50, ['xchange', 'clerk'], MOUSE_LEFT) then
wait(randomRange(1000, 2000));
FailCount := FailCount + 1;
if FailTimer.getTime() > TIMEOUT or FailCount > 5 then
exit;
until grandExchange.isOpen(4000) or (not isLoggedIn());
result := grandExchange.isOpen(500);
end;

I'm not overly happy with it, but it works allot better then my TPA/ATPA version. Anyone have any suggestions to clean it up a little?

Fitta

2015-04-14 17:40:04

From: lovebotter
Hey,

What do you guys think about this GE open function;

function openGE(): boolean;
var
FailCount, x, y: integer;
begin
if not isLoggedIn() then
exit;
FailTimer.start();
repeat
if mainscreen.findObject(x, y, 3611949, 4, colorSetting(2, 0.7, 1.1), mainscreen.playerPoint, 50, 110, 50, ['xchange', 'clerk'], MOUSE_LEFT) then
wait(randomRange(1000, 2000));
FailCount := FailCount + 1;
if FailTimer.getTime() > TIMEOUT or FailCount > 5 then
exit;
until grandExchange.isOpen(4000) or (not isLoggedIn());
result := grandExchange.isOpen(500);
end;

I'm not overly happy with it, but it works allot better then my TPA/ATPA version. Anyone have any suggestions to clean it up a little?


Great use of both timers, failcounts and logic :)
Try to keep stuff a bit more clean, other than that, good work!


function openGE(): Boolean;
var
FailCount, X, Y: integer;
begin
If (Not isLoggedIn()) then
Exit;
FailTimer.Start();
repeat
if MainScreen.findObject(X, Y, 3611949, 4, colorSetting(2, 0.7, 1.1), MainScreen.playerPoint, 50, 110, 50, ['xchange', 'clerk'], MOUSE_LEFT) then
Wait(RandomRange(1000, 2000));
Inc(FailCount);
if (FailTimer.getTime() > TIMEOUT)or(FailCount > 5)then
Exit;
until(GrandExchange.isOpen(4000))or(Not isLoggedIn());
Result := GrandExchange.isOpen(500);
end;

Thomas

2015-04-14 17:46:12

If I put the 'not logid in' exit in the repeat, along with the timer and counter, I believe I can change the result to exit(true), and eliminate a kinda duplicate ge.open check?

Like so:
function openGE(): boolean;
var
i, x, y: integer;
begin
if not isLoggedIn() then
exit;
FailTimer.start();
repeat
if mainscreen.findObject(x, y, 3611949, 4, colorSetting(2, 0.7, 1.1), mainscreen.playerPoint, 40, 90, 50, ['xchange', 'clerk'], MOUSE_LEFT) then
wait(randomRange(1000, 2000));
if FailTimer.getTime() > TIMEOUT or (not isLoggedIn()) then
exit;
until grandExchange.isOpen(4000);
exit(true);
end;
Removed the failcounter. Just a timer would be plenty.

Tweaked it a little more:
function openGE(): boolean;
var
x, y: integer;
begin
FailTimer.start();
repeat
if FailTimer.getTime() > TIMEOUT or (not isLoggedIn()) then
exit;
if mainscreen.findObject(x, y, 3611949, 4, colorSetting(2, 0.7, 1.1), mainscreen.playerPoint, 40, 90, 50, ['xchange', 'clerk'], MOUSE_LEFT) then
wait(randomRange(1000, 2000));
until grandExchange.isOpen(4000);
exit(true);
end;