This is to help call schedules at a different time, or you can just make them be called at a specific time.
void addToSchedule(
string type - Can by anything, but when you release the schedules, it goes by this type.
string function - The function, example: talk
int milliseconds - In milliseconds, when do you want the function to be called after the release?
string[0,15] type - Goes up to 15 args, probably. These are the arguments you can put for the function.
)
void releaseSchedules(
string type - Releases all schedules by their type when they were added to the schedule list.
)
void clearSchedules(
string type - Clears and cancels all schedules by their type when they were added to the schedule list.
)
Here are some examples
addToSchedule("test","talk",300,"testing 1 2 3");
addToSchedule("test","talk",1000,"hi! i'm testing..!");
addToSchedule("test","talk",1500,"yes! i'm testing..!");
addToSchedule("test","talk",2000,"yeah! i'm really testing..!");
releaseSchedules("test");
The code is here.
//Remember this
//Each global var, there will be a tab in between
// $Schedules::All_[%num] = %type %func %ms %arg[0,15]
// or
// $Schedules::Type_[%num] = %func %ms %arg[0,15]
function releaseSchedules(%type)
{
if($Schedules_["Total",%type] <= 0)
{
error("You cannot release empty schedules.");
return;
}
if(!strLen(%type)) %type = "ALL";
cancel($ClearSch);
if(%type $= "ALL")
{
for(%i=0;%i<$Schedules_["Total",%type];%i++)
{
%main = $Schedules_[%type,%i];
%main = strReplace(%main,"\t","" TAB "");
//echo("Detected schedule: " NL %main);
%func = getField(%main,1);
%ms = getField(%main,2);
if(%func !$= "")
{
%crap = "";
for(%a=3;%a<17;%a++)
{
%str = getField(%main,%a) @ ", ";
if(%str !$= ", ") %crap = %crap @ "\"" @ %str @ "\"";
}
if(%crap !$= "")
{
%stuff = getSubStr(%crap,strLen(%crap)-4,4);
%crap = getSubStr(%crap,0,strLen(%crap)-4) @ strReplace(%stuff,", ","");
}
$Schedule_["ALL",%i] = schedule(%ms,0,eval,%func @ "(" @ %crap @ ");");
if(%ms > %bestMS) %bestMS = %ms;
}
$Schedule_["Total",%type]++;
}
}
else
{
//echo("Found " @ $Schedules_["Total",%type] @ " schedules to order.");
for(%i=0;%i<$Schedules_["Total",%type];%i++)
{
%main = $Schedules_[%type,%i];
%main = strReplace(%main,"\t","" TAB "");
//echo(" -> Detected schedule: " NL %main);
%func = getField(%main,0);
%ms = getField(%main,1);
if(%func !$= "")
{
%crap = "";
for(%a=2;%a<17;%a++)
{
%str = getField(%main,%a) @ ", ";
if(%str !$= ", ") %crap = %crap @ "\"" @ %str @ "\"";
}
if(%crap !$= "")
{
%stuff = getSubStr(%crap,strLen(%crap)-4,4);
%crap = getSubStr(%crap,0,strLen(%crap)-4) @ strReplace(%stuff,", ","");
}
$Schedule_[%type,%i] = schedule(%ms,0,eval,%func @ "(" @ %crap @ ");");
if(%ms > %bestMS) %bestMS = %ms;
}
$Schedule_["Total",%type]++;
}
}
$ClearSch = schedule(%bestMS,0,clearSchedules,%type);
}
//If %type is blank all holding schedules will be deleted and canceled
function clearSchedules(%type)
{
if($Schedules_["Total",%type] <= 0)
{
error("You cannot cancel empty schedules.");
return;
}
if(!strLen(%type)) %type = "ALL";
if($Schedule_["Total",%type] > 0)
{
for(%i=0;%i<$Schedule_["Total",%type];%i++)
cancel($Schedule_[%type,%i]);
}
deleteVariables("$Schedule_" @ %type @ "*");
deleteVariables("$Schedules_" @ %type @ "*");
$Schedules_["Total",%type] = 0;
$Schedule_["Total",%type] = 0;
}
function addToSchedule(%type,%func,%ms,%arg0,%arg1,%arg2,%arg3,%arg4,%arg5,%arg6,%arg7,%arg8,%arg9,%arg10,%arg11,%arg12,%arg13,%arg14,%arg15)
{
if(!strLen(%type)) %type = "ALL";
for(%i=0;%i<15;%i++)
%args = %args TAB %arg[%i];
%args = trim(%args);
if(%type $= "all") $Schedules_["ALL",$Schedules_["Total",%type]] = %type TAB %func TAB %ms TAB %args;
else $Schedules_[%type,$Schedules_["Total",%type]] = %func TAB %ms TAB %args;
$Schedules_["Total",%type]++;
}