Originally Posted by
Grimtoker
...
Really good start mate. Is coming along really well!
A few things you can do to optimize.
You have create a variable called pnt and assigned [295, 210] to it. As far as I can see, you only use it on the next line. A more efficient way to do this is to not create a variable called pnt, but rather assign the variables straight into the HumanMMouse function like so:
Simba Code:
HumanMMouse(Point(295, 210), 10, 10);
This means you don't have to spend a line creating a TPoint variable, and then another line assigning values to the variable if it is only going to be used once.
Also with your glass blowing, you can add a while..do component to the script to speed it up.
Simba Code:
procedure Blowing;
var
pnt : Tpoint;
waitCount: integer; //Create a variable that we will be using to count the time its taken to blow the glass.
begin
Writeln('Selecting items');
Pipe.interact(MOUSE_LEFT);
wait(750+random(750));
Glass.interact(MOUSE_LEFT);
wait(1000+random(750));
Writeln('Making lens');
HumanMMouse(Point(295, 210), 10, 10);
FastClick(Mouse_right);
wait(1750+random(750));
if WaitOption('Make X', 1000) then
ChooseOption('Make X');
wait(1750+random(750));
SendKeys('88', 100, 30);
wait(500+random(500));
KeyDown(13);
wait(RandomRange(50, 100));
KeyUp(13);
Writeln('Blowing started!');
while Glass.findIn(AREA_Inv, pnt) do //Creates a loop that will continue to see if the glass item is found in our inventory. If it is present, it will fire all items between the begin/end statements.
begin
wait(1000); // waits 1000ms
inc(waitCount); //increases the number assigned to waitCount by 1.
if (waitCount > 58) then //Checks to see if we have waited our maximum time. In this case 58 seconds.
Break; //Breaks out of the While..Do loop.
end; // Once there is no more glass in the inventory, it will break out of the loop and continue on with the script.
CurrentTask := BANK;
end;
The benefit of this will be that if the glass making finishes earlier, it will start banking, rather than waiting the 55 + 10 seconds. We have a 58 second counter there to stop the script from failing and falling into an infinite loop though, so after 58 seconds, if the inventory is still not done, it will bank.
A more efficient way to do this again would be to count the inventory in smaller times. This allows us to get back to making when we level up or stop blowing glass for whatever reason (less bot like).
To do this, you would be best off making a separate procedure for monitoring your glass make. See revised script:
Simba Code:
program GlassLens;
{$i AeroLib/AeroLib.Simba}
type
ScriptState = (BLOW, BANK, WAITING);
var
BankObject : TMSObject;
CurrentTask: ScriptState;
Pipe:TItem;
Glass:TItem;
Lens:TItem;
Procedure PlayerSetup;
begin
Me.Active := True;
Me.Name := '';
Me.Pass := '';
Me.Member := True;
BankObject.create('Use Bank chest', ['Bank', 'chest', 'Use'], [createCol(2767439, 12, 0.04, 0.19)], 50, 0, 0, 0);
CurrentTask := BLOW;
end;
Procedure LoadItems; //Thanks to the DTM guide!
begin
Pipe.DTM := DTMFromString('mFQEAAHiclc1LCoAwDEXRp1IQtX6wQgvi1jp0/zvwQjNxmAcng5BPlDRhRECvlsH6Gw4knNgRseJCwY1sM7Ptym4Fu73grZXauTzyx/eh+eUD8p8CoQ==');
Glass.DTM := DTMFromString('mFQEAAHic42VgYOAHYg4gZmSAAE4g5oGKSwKxFJQWA2JhqDgXVC0zlM0HxIJALARls0HlGKDmsgDx9a0roDzisSTUblIwaTYg/A0HAAVQBMQ=');
Lens.DTM := DTMFromString('mwQAAAHic42RgYOABYi4gZgViRgYIALH5gVgEiAWhakCACYjZoHLiQCwKxLxAzAzE+kY2UBNwY0kGwgC/CQg3ggEAxM8BhQ==');
end;
procedure Blowing;
var
pnt : Tpoint;
begin
Writeln('Selecting items');
Pipe.interact(MOUSE_LEFT);
wait(750+random(750));
Glass.interact(MOUSE_LEFT);
wait(1000+random(750));
Writeln('Making lens');
HumanMMouse(Point(295, 210), 10, 10);
FastClick(Mouse_right);
wait(1750+random(750));
if WaitOption('Make X', 1000) then
ChooseOption('Make X');
wait(1750+random(750));
SendKeys('88', 100, 30);
wait(500+random(500));
KeyDown(13);
wait(RandomRange(50, 100));
KeyUp(13);
Writeln('Blowing started!');
CurrentTask := WAITING;
end;
procedure WaitingForGlass;
var
waitCount, CurrentInvCount: integer;
pnt: Tpoint;
begin
CurrentInvCount := Glass.getAmount(true); // Sets CurrentInvCount to the number of uncrafted glass we have in our inventory.
repeat //Starts our repeat statement
wait(100);
if (CurrentInvCount = Glass.getAmount(true)) then //Checks to see if our CurrentInvCount variable is still equal to our number of uncrafted glass in our inventory.
inc(WaitCount); // if so, it increases the waitCount variable.
if (WaitCount >= 50) then // if WaitCount has a value greater than or equal to 50 (5 seconds), we have stopped crafting glass.
begin
WriteLn('We have stopped blowing glass. Starting again.');
CurrentTask := BLOW; //We set the Current task to the procedure blow to start blowing glass again.
Exit; //We exit the current procedure, which takes us back to the MainLoop procedure, where it will choose BLOW.
end;
Until(CurrentInvCount > Glass.getAmount(true)); // Will finish the repeat/Until statement if our CurrentInvCount variable is more than the current amount of uncrafted glass.
if Glass.findIn(Area_Inv, pnt) then //Will do a check to see if there is any more glass left.
begin
Writeln('We have finished making glass');
CurrentTask := BANK; // There is no more glass left, so we are setting CurrentTask to BANK.
end;
end; //Procedure will pass to BANK or Repeat WAITING depending on the above if/then statement. If we still have glass in our inventory, the script will go back to Mainloop, check the value of CurrentTask, identify its still WAITING, then repeat this procedure again.
procedure Banking;
var
BankPoint : TPoint;
pnt : Tpoint;
begin
Writeln('Opening Bank..');
if BankObject.find(BankPoint) then
begin
wait(2000+random(750));
openBankPoint(BankPoint, true);
Writeln('Deposting..');
wait(2000+random(750));
end
quickDeposit('inventory');
Writeln('Withdrawing..');
wait(1750+random(750));
withdrawItem(Glass, -1);
wait(1750+random(750));
KeyDown(27);
wait(RandomRange(50, 100));
KeyUp(27);
wait(1750+random(750));
Writeln('Success!');
CurrentTask := BLOW;
ClearDebug;
end;
Procedure MainLoop;
begin
if not isLoggedIn then
TerminateScript;
case CurrentTask of
BLOW: Blowing();
BANK: Banking();
WAITING: WaitingForGlass();
end
end;
begin
initAL;
PlayerSetup;
LoadItems;
repeat
MainLoop();
Until(False);
end.
Not sure if I broke it or not, but let me know if it works lol.