Author Topic: Wait procedure messed up?  (Read 733 times)

Offline Dasio11

  • Leecher
  • Posts: 4
  • Rep: 0
    • View Profile
    • Email
Wait procedure messed up?
« on: November 03, 2009, 11:23:31 am »
Hi, I have written a script that withdraws iron ores and coal from bank, smelts them into steel bars in the Al-kharid furnace and stores them back. It used to work very well and has already smelted like 8000 bars, left alone for hours. However, a glitch has recently appeared, that makes the script work too fast and my characeter comes back to bank with 1 iron+2coal not smelted or searches for the furnace too early. I think the Wait procedure is the problem, as it waits less than requested (like 0.7 second when supposed to wait 1000ms). I know I can just tell it to wait more "shortered-seconds" to make it work properly, but it would wait too much while trying to wait "proper amount of time". I also know it's ridiculous, but I want the script to work as quickly as can be without major changes. I doubt if posting whole the script will help, but you might want to take a look at it:

Code: [Select]
program AutoSmelter;
//Before using pick all every-time colors up and specify the RS window

const
Banker = 3760010;   //Banker color (picked once)
Carpet = 1383533;     //Carpet color  (picked rather once)
Furnace = 926856;    //Furnace color (picked every time)
Kebab = 2194790;     //... (picked once)
Bush = 3370320;     //Bush-in-front-of-the-bank color (picked every time)
Steel = 6316132;     // Steel bar color (picked once)

var
l, t, x, y,  xi, yi, xc, yc, iron, coal: Integer;
Vital: Boolean;

 

begin
ClearDebug;
l:=0;
PickColor(iron, xi, yi);         //Position of iron ore in bank window
PickColor(coal, xc, yc);            //Position of coal in bank window
Wait(4000);


repeat

  if(FindColorTolerance(x, y, Banker, 0, 150, 1280, 1024, 3)) then
    begin
      ClickMouse(x+3,y+10, false);
      Wait(600);
      ClickMouse(x+5, y+54,true);        //Bank banker
      Wait(2000);
      ClickMouse(1160, 450, false);
      Wait(500);
      ClickMouse(1160, 557, true);       //Store all steel bars
      Wait(1000);
      for t:=0 to 5 do
        if (FindColor(x, y, Steel, 1090, 431, 1268, 682)) or
           (FindColor(x, y,  Iron, 1090, 431, 1268, 682)) then  //if skipped any steel or iron
               begin
                 ClickMouse(x, y, false);     //then redo banking them
                 Wait(1000);
                 ClickMouse(x, y+107, true);
                 Wait(1000);
               end;
      ClickMouse(xi, yi ,false);
      Wait(500);
      ClickMouse(xi, yi+75, true);     //Take out 10 iron ores
      Wait(500);
      if (GetColor(xc, yc)=coal) then    //if there is still any coal to smelt
        begin
          ClickMouse(xc, yc, false);
          Wait(500);
          ClickMouse(xc, yc+110, true);   //Take out as much coal as possible
          Wait(500);
        end else if(GetColor(xi,yi)=iron) then Exit;
         
    end else
    begin
      WriteLn('Cannot find any banker :/');
    end;
   
  if(Findcolor(x, y, Kebab, 1103, 1, 1256, 70)) then
    begin
      ClickMouse(x+2, y, true);
      Wait(18000);
    end else WriteLn('Cannot find kebab :/');
   
  if not(FindColor(x, y, 65280,   1082, 120, 1101, 130)) then  //checks if my run energy is higher than 75
      begin
        Vital:=false;
        t:=16000;
      end else
      begin
        Vital:=true;
        t:=12000;
      end;
     
  if(Vital) then KeyDown(17);                                  //So it runs or not (17 is left control key)
   


  if(FindColorTolerance(x, y, Furnace, 0, 0, 1280, 1024, 8)) then
    begin
      ClickMouse(x,y, true);
      Wait(t);
      ClickMouse(257, 642, false);
      Wait(500);
      ClickMouse(257, 688, true); //smelt 10 steel bars
      Wait(500);
      MoveMouse(100,100);
      Wait(27000);
      l:=l+9;
    end else
    begin
      WriteLn('Cannot find the Furnace :/');
    end;

  if  (GetColor(253, 684)=16711680) then  //if levelled up
    begin
      if(FindColorTolerance(x, y, Furnace, 0, 0, 1280, 1024, 8)) then
        begin
          ClickMouse(x,y, true);
          Wait(1000);
          ClickMouse(257, 642, false);
          Wait(500);
          ClickMouse(257, 688, true); //smelt 10 steel bars
          Wait(23000);
        end else WriteLn('Couldnt re-find the furnace');
    end;
   

  if not(Vital) then KeyDown(17);
 
   
  if(Findcolor(x, y, Bush, 1136, 133, 1230, 158)) then
    begin
      ClickMouse(x, y, true);
     Wait(11000);
    end else
      begin
        WriteLn('Cannot find the bush :/');
      end;

   
   
  if(FindColor(x, y, Carpet, 0, 0, 401, 540)) then
    begin
      ClickMouse(x,y,true);
      Wait(5000);
    end else
    begin
      WriteLn('Cannot find the carpet :/');
    end;
   
  KeyUp(17);

WriteLn('Already smelted ' +IntToStr(l) +' bars.');



until(false);

end.

Sorry for any possible English language mistakes ;p
« Last Edit: February 27, 2011, 03:52:04 am by Dasio11 »

Freddy1990.com

Wait procedure messed up?
« on: November 03, 2009, 11:23:31 am »

tvirusx1

  • Guest
Re: Wait procedure messed up?
« Reply #1 on: December 24, 2009, 04:55:56 am »
You should make the Script look if you have smelted all bars.
When you smelt a whole inventory of Iron and Coal into steel, make the Script look for a color where the Last Steel bar would be.

Heres a quick example:
[scar]program CheckBars;
const
SteelColor = 1048728; //I just put a random number there.
var
x,y :integer;

begin
    if(FindColor(x, y, SteelColor, 811, 645, 811, 645) = true) then  //I used random Co-Ords here, but you should use the Co-Ords of the last Steel Bar
    begin
        //go to bank, bank the steel bars
    end;
//you can use 'else' but I like it this way
    if(FindColor(x, y, SteelColor, 811, 645, 811, 645) = false) then  //same coords as above
    begin
        //go to furnace, create steel bars
    end;
end.[/scar]

I hope you understand what I mean.

Freddy1990.com

Re: Wait procedure messed up?
« Reply #1 on: December 24, 2009, 04:55:56 am »

Offline Dasio11

  • Leecher
  • Posts: 4
  • Rep: 0
    • View Profile
    • Email
Re: Wait procedure messed up?
« Reply #2 on: March 24, 2010, 09:52:26 am »
Hmm, that's a rational way, thanks :) You have however no idea, why Wait(...) goes wrong?...
One more thing: the environment the script works in isn't plain, so it might sometimes fail to do something, skip it and start another turn (it has already succesfully done so). If I place a while(notsmelted) loop, it might crash if it hasn't started smelting for some reason :-/
« Last Edit: March 24, 2010, 09:58:50 am by Dasio11 »

Offline s2h6699

  • Newbie
  • *
  • Posts: 22
  • Rep: 0
    • View Profile
Re: Wait procedure messed up?
« Reply #3 on: March 26, 2010, 08:49:19 am »
You sure this is your first script? This is pretty good.

Offline Dasio11

  • Leecher
  • Posts: 4
  • Rep: 0
    • View Profile
    • Email
Re: Wait procedure messed up?
« Reply #4 on: March 26, 2010, 02:51:57 pm »
@s2h6699: Well, not absolutely the first, maybe first useful one.

Problem: now it is all screwed most ever. My Windows clock started running like 1.25 second per second... when I ran this script. Could Scar ever affect my computer clock?? This is just rubbish... but true :-/
Does anybody suspect, what might it be :-|
P.S. Winamp clock goes OK... possible?
P.S.2. After resetting the computer problem disappeared.
« Last Edit: March 27, 2010, 04:14:12 am by Dasio11 »

Freddy1990.com

Re: Wait procedure messed up?
« Reply #4 on: March 26, 2010, 02:51:57 pm »

Offline Freddy

  • Owner
  • *****
  • Posts: 2616
  • Rep: 19
    • MSN Messenger - freddy1990@gmail.com
    • AOL Instant Messenger - Freddy199O
    • View Profile
    • Email
Re: Wait procedure messed up?
« Reply #5 on: March 27, 2010, 04:00:55 am »
@s2h6699: Well, not absolutely the first, maybe first useful one.

Problem: now it is all screwed most ever. My Windows clock started running like 1.25 second per second... when I ran this script. Could Scar ever affect my computer clock?? This is just rubbish... but true :-/
Does anybody suspect, what might it be :-|
P.S. Winamp clock goes OK... possible?
Hmm, that's not possible... Srsly, it just isn't...

Offline Dasio11

  • Leecher
  • Posts: 4
  • Rep: 0
    • View Profile
    • Email
Re: Wait procedure messed up?
« Reply #6 on: March 27, 2010, 08:52:52 am »
Today I set the script for like 6 hours, it is all correct with it's work but Windows clock went 20 minutes forwards again... Although I had synchronized it today morning (my watch shows 17:00 whereas computer clock says 17:20). Any ideas? :O
« Last Edit: March 29, 2010, 11:16:26 am by Dasio11 »

Freddy1990.com

Re: Wait procedure messed up?
« Reply #6 on: March 27, 2010, 08:52:52 am »

 

deductible-aliform