Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cron/cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var cron = cron || {
jobsToFire.sort();
if (newCount < oldCount){ jobsToFire.reverse(); }
for (var i = 0; i < jobsToFire.length; i++){
cron.handleJob(state.cron.countJobs[jobsToFire[i]]);
cron.handleJob(state.cron.countJobs[jobsToFire[i][1]]);
}
for (var i = 0; i < jobsToDelete.length; i++){
delete state.cron.countJobs[jobsToDelete[i]];
Expand Down Expand Up @@ -404,6 +404,15 @@ var cron = cron || {
else{ doCount = true; }
}
args['interval'] = cron.parseInterval(args['interval']);
if (doCount){
if (!args.hasOwnProperty('rounds')){
args['rounds'] = args['interval'];
}
if (!args.hasOwnProperty('count')){
var turns = JSON.parse(Campaign().get('turnorder') || "[]");
args['count'] = (turns.length > 0 ? turns[0].pr : 0);
}
}
}
if ((doCount) && (doTimed)){
cron.write("Error: Cannot mix initiative-based and timed jobs", msg.who, "", "CronD");
Expand All @@ -430,6 +439,7 @@ var cron = cron || {

registerCron: function(){
cron.init();
on("change:campaign:turnorder", cron.handleTurnChange);
if ((typeof(Shell) != "undefined") && (Shell) && (Shell.registerCommand)){
Shell.registerCommand("!cron", "!cron [options] command", "Schedule a command to run in the future", cron.handleCronMessage);
if (Shell.write){
Expand Down
2 changes: 1 addition & 1 deletion cron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cron",
"version": "0.2",
"version": "0.3",
"description": "Schedule (possibly recurring) commands to run at some point in the future.",
"authors": "manveti",
"roll20userid": "503018",
Expand Down