Cigue
2010-07-19 19:39:55
Periodic collection is the single most profitable activity in runescape.
Here are a few functions that work just like TimeFromMark and MarkTime. Those are two of the functions I use the most in failsafes, and I figure that everyone should. However, there is a core application that these do not cover, like the kind of timing you'd need for a farming script.
Introducing MarkTimeINI and TimeFromMarkINI.
These are time marks that you can write in one script and read in another, or that you can read from a past occurence of the same script. As an example, a periodic collection script would need to know before execution if it has been run recently, because you can only collect these every 24 hours.
If you think these scripts are useless because you haven't seen them before, you're wrong : periodic collection is the most profitable repeatable group of activities in runescape, sometimes neighbouring up to several millions of profit per hour doing perfectly legit activities.
The reason why you haven't seen these is that there were no means of providing the timing functions necessary to these scripts by the past : you cannot run a broad bolt collection script more than every 24 hours, etc.
About two thirds of collection activities, however, reset every GMT midnight instead of 24 hours after the last run. A third function would be of use here for which I haven't found a good name, so let's call it HasMidnightPassedINI. The parameters include the timezone the script user is in, however, so this function is not for use outside of scripts that completely require its use.
Here are a few functions that work just like TimeFromMark and MarkTime. Those are two of the functions I use the most in failsafes, and I figure that everyone should. However, there is a core application that these do not cover, like the kind of timing you'd need for a farming script.
Introducing MarkTimeINI and TimeFromMarkINI.
These are time marks that you can write in one script and read in another, or that you can read from a past occurence of the same script. As an example, a periodic collection script would need to know before execution if it has been run recently, because you can only collect these every 24 hours.
If you think these scripts are useless because you haven't seen them before, you're wrong : periodic collection is the most profitable repeatable group of activities in runescape, sometimes neighbouring up to several millions of profit per hour doing perfectly legit activities.
The reason why you haven't seen these is that there were no means of providing the timing functions necessary to these scripts by the past : you cannot run a broad bolt collection script more than every 24 hours, etc.
About two thirds of collection activities, however, reset every GMT midnight instead of 24 hours after the last run. A third function would be of use here for which I haven't found a good name, so let's call it HasMidnightPassedINI. The parameters include the timezone the script user is in, however, so this function is not for use outside of scripts that completely require its use.
{$i SRL/SRL.scar}
var INIFilePath : string;
procedure MarkTimeINI(Mark : String);
begin
if INIFilePath = '' then INIFilePath := ScriptPath + 'ScriptInstructions.ini';
WriteINI('Time Marks', Mark, TheTime + ' ' + TheDate(3), INIFilePath);
end;
function TimeFromMarkINI(Mark: String) : integer;
var
LH, LDBM, CH, CDBM, i : integer;
DaysInMonthLY, DaysInMonthCY : TIntegerArray;
LRA, CRA : TStringArray;
LRAA, CRAA : array [0..1] of TStringArray;
begin
if INIFilePath = '' then INIFilePath := ScriptPath + 'ScriptInstructions.ini';
SetArrayLength(LRA, 3);
SetArrayLength(CRA, 3);
SetArrayLength(LRAA[0], 3);
SetArrayLength(LRAA[1], 3);
SetArrayLength(CRAA[0], 3);
SetArrayLength(CRAA[1], 3);
LRA := srl_Explode(ReadINI('Time Marks', Mark, INIFilePath), ' ');
LRAA[0] := srl_Explode(LRA[0], ':');
LRAA[1] := srl_Explode(LRA[2], '-');
CRA := srl_Explode(TheTime + ' ' + TheDate(3), ' ');
CRAA[0] := srl_Explode(CRA[0], ':');
CRAA[1] := srl_Explode(CRA[2], '-');
CH := StrToInt(CRAA[0][0]);
if (CRA[1] = 'PM') then IncEx(CH, 12);
LH := StrToInt(LRAA[0][0]);
if (LRA[1] = 'PM') then IncEx(LH, 12);
SetArrayLength(DaysInMonthLY, 12);
SetArrayLength(DaysInMonthCY, 12);
DaysInMonthLY := [31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30];
DaysInMonthCY := [31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30];
if ((StrToInt(LRAA[1][0]) mod 4) = 0) then
Inc(DaysInMonthLY[1]);
if (StrToInt(CRAA[1][0]) mod 4 = 0) then
Inc(DaysInMonthCY[1]);
for i := 0 to (StrToInt(CRAA[1][1]) - 1) do
IncEx(CDBM, DaysInMonthCY[i]);
for i := 0 to (StrToInt(LRAA[1][1]) - 1) do
IncEx(LDBM, DaysInMonthLY[i]);
Result := (StrToInt(CRAA[0][2]) - StrToInt(LRAA[0][2])) + 3600*(CH - LH);
Result := Result + 60*(StrToInt(CRAA[0][1]) - StrToInt(LRAA[0][1]));
Result := Result + 86400*(StrToInt(CRAA[1][2]) - StrToInt(LRAA[1][2]) + CDBM - LDBM);
Result := Result + 31536000*(StrToInt(CRAA[1][0]) - StrToInt(LRAA[1][0]));
end;
function HasMidnightPassedINI(Mark : string; TimeZone : extended) : Boolean;
var
MidnightHour, MidnightMinutes : string;
TempHour : integer;
begin
if INIFilePath = '' then INIFilePath := ScriptPath + 'ScriptInstructions.ini';
if (TimeZone > 12) or (TimeZone < -12) then
begin
srl_Warn('HasMidnightPassedINI', 'Invalid Timezone parameter', 1);
Exit;
end;
MidnightHour := IntToStr(Floor(TimeZone));
if TimeZone < 0 then
TempHour := Ceil(TimeZone)
else
TempHour := Floor(TimeZone);
WriteINI('Time Marks', 'ThisIsMidnight', MidnightHour + ':' + MidnightMinutes + ':00 AM ' + TheDate(3), INIFilePath);
if (TimeFromMarkINI(Mark) > TimeFromMarkINI('ThisIsMidnight')) then Result := True;
end;
begin//This bit is just testing the procedure to see what it does
MarkTimeINI('Mark1');
Wait(RandomRange(10000, 20000));
Writeln(IntToStr(TimeFromMarkINI('Mark1')) + ' seconds elapsed since last mark');
if HasMidnightPassedINI('Mark1', -5.30) then Writeln('Midnight has passed');
end.