Timing¶
The Timing include contains a lot of timing related functions.
Contents
- Timing
- MsToTime
- TimeRunning
- MarkTime
- TimeFromMark
- TheTime
- TheDate
- WaitFuncEx
- WaitFunc
- WaitOptionMultiEx
- WaitOptionMulti
- WaitOptionEx
- WaitOption
- WaitUpTextMulti
- WaitUptext
- WaitInvCount
- WaitInvMaxCount
- WaitInvMinCount
- WaitColor
- WaitFindColor
- WaitFindColors
- WaitColorCount
- WaitColorGone
- WaitColorGoneIn
- WaitFindDTMEx
- WaitFindDTM
- WaitTabExists
- WaitNPCTalking
MsToTime¶
function MsToTime(MS, StrType: Integer): string;
Takes MS in milliseconds and outputs a string with hours, mins and seconds. Different styles can be created with different StrType values: Str Type:
- Time_Formal: 2 Hours, 47 Minutes and 28 Seconds
- Time_Short: 02h, 47m, 28s
- Time_Abbrev: 2 hr, 47 min, 28 sec
- Time_Bare: 02:47:28
- Time_FStop: 12.04.40
Note
by Zephyrsfury, Nava2 and Rasta Magician.
Example:
TimeRunning¶
function TimeRunning: String;
Returns Time since the script was started (GetTimeRunning).
Note
by Rasta Magician.
Example:
MarkTime¶
procedure MarkTime(var TimeMarker: Integer);
Sets TimeMarker to current system time
Note
by Stupid3ooo
Example:
TimeFromMark¶
function TimeFromMark(TimeMarker: Integer): Integer;
Returns Milliseconds since MarkTime was set
Note
by Stupid3ooo
Example:
TheTime¶
function TheTime(FullTime : boolean) : string;
Returns current time as a string FullTime = True will return in 24 hours rather than 12 hours
Note
by RsN (fixed by Ron and Markus)
Example:
TheDate¶
function TheDate(DateFormat : Integer) : String;
TheDate will return the current date. DateFormats can be:
- Date_Formal = April 2nd, 2007 Month Day, Year
- Date_Month = 04/02/07 Month/Day/Year
- Date_Day = 02-04-07 Day-Month-Year
Note
by Ron, Nava2 & Narcle
Example:
WaitFuncEx¶
function WaitFuncEx(Func: string; var Args: TVariantArray; WaitPerLoop, MaxWait: integer): boolean;
Calls Func with arguments Args every WaitPerLoop milliseconds for a max of MaxWait milliseconds. Func can return any basic types (boolean, string, integer). Boolean: Returns it. String: Returns true if string equals ‘true’. Integer: Returns true unless it equals 0.
Note
by Dgby714
Example:
var
V: TVariantArray;
begin
V := [0, 0, 16711680, 4, 4, 500, 500];
WriteLn(WaitFuncEx('FindColorEx', V, 10 + Random(15), 1000));
end.
WaitFunc¶
function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean;
Waits for function Func to be true. WaitPerLoop is how often you want to call “Func” function. Example: “WaitFunc(@BankScreen, 10 + Random(15), 750);” will check if BankScreen is open every 10-25th millisecond, for a maximum of 750 milliseconds. Notice the ‘@’.
Note
by Rasta Magician, small edit by EvilChicken!
Example:
WaitOptionMultiEx¶
function WaitOptionMultiEx(S: TStringArray; TextType: string;
Action: fnct_ActionOptions; Time: Integer): Boolean;
Waits for a TStringArray of options and selects one of them. Searches for TextType you input. ‘action’, ‘player’: The white text ‘item’: The orange text ‘npc’: The yellow text ‘object’: The cyan text ‘all’: Searches for all colors of text. Will default to ‘all’.
Note
by Infantry001
Example:
WaitOptionMulti¶
function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
Waits for a TStringArray of options and selects one of them
Note
by Marpis, N1ke! & Rasta Magician
Example:
WaitOptionEx¶
function WaitOptionEx(S, TextType: String; Time: Integer): Boolean;
Waits for an Option and selects it. Searches for TextType.
Note
by Infantry001
Example:
WaitOption¶
function WaitOption(S: String; Time: Integer): Boolean;
Waits for an Option and selects it
Note
by N1ke!
Example:
WaitUpTextMulti¶
function WaitUpTextMulti(S: TStringArray; Time: integer): Boolean;
Waits for a TStringArray of UpText, returns true if found
Note
by Marpis & N1ke!
Example:
WaitUptext¶
function WaitUptext(S: String; Time: Integer): Boolean;
Waits for an UpText, returns true if found
Note
by Marpis edited by N1ke!
Example:
WaitInvCount¶
function WaitInvCount(Count, MaxTime: Integer; CountType: (MaxCT, MinCT, ExactCT)): boolean;
Waits for a maximum inv count. Returns true if InvCount <= Count
Note
by Rasta Magician
Example:
WaitInvMaxCount¶
function WaitInvMaxCount(Count, MaxTime: integer): boolean;
Waits for a maximum inv count. Returns true if InvCount <= Count
Note
by Rasta Magician.
Example:
WaitInvMinCount¶
function WaitInvMinCount(Count, MaxTime: integer): boolean;
Waits for a minimum inv count. Returns true if InvCount >= Count
Note
by Rasta Magician
Example:
WaitColor¶
function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
Waits for a color at (x, y) with tolerance Tol, returns true if found
Note
by Rasta Magician, fixed by TRiLeZ
Example:
WaitFindColor¶
function WaitFindColor(var x, y: integer; Color, Tol, x1, y1, x2, y2, MaxTime: integer): Boolean;
Waits for a color at (x, y) with tolerance Tol, returns true if found
Note
by Rasta Magician, fixed by TRiLeZ
Example:
WaitFindColors¶
function WaitFindColors(var x, y: integer; Color, Tol, x1, y1, x2, y2, MaxTime: integer): Boolean;
Waits for a color at (x, y) with tolerance Tol, returns true if found
Note
by IceFire908 based completely off WaitFindColor
Example:
WaitColorCount¶
function WaitColorCount(Color, x1, y1, x2, y2, Tol, MinCount, MaxCount, MaxTime: integer):boolean;
Waits Color count in box (x1, y1, x2, y2) with Tol
Note
by Rasta Magician
Example:
WaitColorGone¶
function WaitColorGone(Color, x, y, Tol, MaxTime: integer): Boolean;
Waits until a colour is gone at (x, y) with tolerance and a timeout. Results true if the colour disappeared at (x, y) within the time cap.
Note
by TRiLeZ
Example:
WaitColorGoneIn¶
function WaitColorGoneIn(Colour, x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;
Waits until a colour is gone in an area with tolerance and a timeout. Results true if the colour disappeared in the area within the time cap.
Note
by TRiLeZ
Example:
WaitFindDTMEx¶
function WaitFindDTM(var x, y: integer; DTM, waitTime: integer): boolean;
waits ‘waitTime’ for the ‘DTM’ to be found. If found, returns true and the DTM’s coodinates in x and y.
Note
Author: Coh3n Last Modified: Mar. 8th, 2012 by beginner5
Example:
if (WaitFindDTM(dtmHatchet, x, y, MIX1, MIY1, MIX2, MIY2, 5000)) then
mouse(x, y, 5, 5, mouse_Left);
WaitFindDTM¶
function WaitFindDTM(var x, y: integer; DTM, waitTime: integer): boolean;
waits ‘waitTime’ for the ‘DTM’ to be found. If found, returns true and the DTM’s coodinates in x and y.
Note
Author: Coh3n Last Modified: Mar. 8th, 2012 by Coh3n
Example:
if (WaitDTM(x, y, dtmHatchet, 5000)) then
mouse(x, y, 5, 5, mouse_Left);
WaitTabExists¶
function WaitTabExists(tab, waitTime: integer): boolean;
waits ‘waitTime’ for the ‘tab’ to exist. Useful for detecting when a player has returned from a random event.
Note
Author: Coh3n Last Modified: Jan. 22nd, 2012 by Coh3n
Example:
if (WaitTabExists(TAB_MAGIC, 5000)) then
writeln('exited the random');
WaitNPCTalking¶
function WaitNPCTalking(NPC: string, waitTime: integer): boolean;
waits ‘waitTime’ for the ‘NPC’ name to appear in the chat box.
Note
Author: Coh3n Last Modified: Jan. 29th, 2012 by Coh3n
Example:
if (WaitNPCTalking(NAME_NPC_GILES, 5000)) then
writeln('Talking to Giles');