Log in

View Full Version : How can i simplify this?



John
05-18-2012, 08:26 AM
I need to simplifiy this procedure, it looks way to messy as it is.

procedure RepairPouches;
var
x, y: integer;
begin
OpenBankCw;
if Withdraw(AstralCollum, AstralRow, 1) then
if Withdraw(CosmicCollum, CosmicRow, 1) then
if Withdraw(AirCollum, AirRow, 2) then
begin
CloseBank;
if GameTab(tab_magic) then
begin
MouseBox(680, 310, 694, 318, MOUSE_LEFT);
Wait(500+random(250));
MouseBox(407, 309, 459, 317, MOUSE_LEFT);
Wait(7000+random(1000));
ClickContinue(False, True);
Wait(800+random(250));
ClickContinue(False, True);
Wait(800+random(250));
ClickContinue(False, True);
Wait(800+random(250));
ClickContinue(False, True);
Wait(800+random(250));
ClickContinue(False, True);
Wait(800+random(250));
ClickContinue(False, True);
SendKeys('1', 300);
Wait(800+random(250));
ClickContinue(False, True);
Wait(800+random(250));
ClickContinue(False, True);
end;
end;
end;

johnbrown8976
05-18-2012, 09:18 AM
I need to simplifiy this procedure, it looks way to messy as it is.



If I were you, I would use a loop (for, while or repeat).

procedure RepairPouches;
var
x, y, i: integer;
begin
OpenBankCw;
if not Withdraw(AstralCollum, AstralRow, 1) then exit;
if not Withdraw(CosmicCollum, CosmicRow, 1) then exit;
if not Withdraw(AirCollum, AirRow, 2) then exit;
if BankScreen then CloseBank;
if not GameTab(tab_magic) then exit;
MouseBox(680, 310, 694, 318, MOUSE_LEFT);
Wait(500+random(250));
MouseBox(407, 309, 459, 317, MOUSE_LEFT);
Wait(7000+random(1000));
for i:=1 to 9 do
begin
if i=7 then
SendKeys('1', 300)
else
ClickContinue(False, True);
Wait(800+random(250));
end;
end;

John
05-18-2012, 09:25 AM
If I were you, I would use a loop (for, while or repeat).

procedure RepairPouches;
var
x, y, i: integer;
begin
OpenBankCw;
if not Withdraw(AstralCollum, AstralRow, 1) then exit;
if not Withdraw(CosmicCollum, CosmicRow, 1) then exit;
if not Withdraw(AirCollum, AirRow, 2) then exit;
if BankScreen then CloseBank;
if not GameTab(tab_magic) then exit;
MouseBox(680, 310, 694, 318, MOUSE_LEFT);
Wait(500+random(250));
MouseBox(407, 309, 459, 317, MOUSE_LEFT);
Wait(7000+random(1000));
for i:=1 to 9 do
begin
if i=7 then
SendKeys('1', 300)
else
ClickContinue(False, True);
Wait(800+random(250));
end;
end;


Man that looks great!
Tysm
E: Why? lol http://puu.sh/vmP1

weequ
05-18-2012, 09:43 AM
You could also consider using and instead of if then if then if then:

procedure RepairPouches;
var
x, y, i: integer;
begin
OpenBankCw;
if Withdraw(AstralCollum, AstralRow, 1) and Withdraw(CosmicCollum, CosmicRow, 1) and Withdraw(AirCollum, AirRow, 2) then
begin
CloseBank;
if GameTab(tab_magic) then
begin
MouseBox(680, 310, 694, 318, MOUSE_LEFT);
Wait(500+random(250));
MouseBox(407, 309, 459, 317, MOUSE_LEFT);
Wait(7000+random(1000));
for i:=1 to 9 do
begin
if i=7 then
SendKeys('1', 300)
else
ClickContinue(False, True);
Wait(800+random(250));
end;
end;
end;