No, sorry. Let me try to expand on this a bit. Macros are a collection of things you could type in chant manually, but don't want to have to type over and over. API programs are written in Javascript and are installed outside of the VTT in the Campaign Details for the Campaign where you want to use them. The API has access to various details of the campaign, as well as the ability to get notified of various events and perform actions. One of the events the API can subscribe to is someone entering a chat message. It would look like this: on('chat:message', function(msg){
log('got a chat message');
}); What Toke has posted is just some functions that handle the clock portion. You would still need to write the chat portion. It could look something like this: var doom_timer = 0; // timer
var x = 0; // total doom
var doom_status = true;
var doom_clock = null;
var doom_interval= (20*60); // 20 minutes
function doom_initialize(initial_x){
x = initial_x;
doom_status = true;
// Run the clock once every 1 seconds
doom_clock = setInterval(function(){
if (doom_status){
doom_timer += 1; // count every seconds
if (doom_timer >= doom_interval ){
doom_timer = 0; // reset count
x += Math.floor((Math.random() * 4) + 1); // add 1d4
}
}
}, 1000);
}
function doom_stop(){
doom_status = false;
}
function doom_start(){
doom_status = true;
}
function doom_count(){
return x;
}
on('ready',function(){
on('chat:message',function(msg){
var args;
if (msg.type !== 'api') {
return;
}
args = msg.content.split(/\s+/);
switch(args[0]) { case '!doom-set': doom_initialize(parseInt(args[1],10) || 0); sendChat('Doomsday Clock','/w gm Set Doomsday Clock to: '+doom_count()); break;
case '!doom-start':
doom_start();
sendChat('Doomsday Clock','/w gm Started Doomsday Clock.');
break;
case '!doom-stop':
doom_stop();
sendChat('Doomsday Clock','/w gm Stopped Doomsday Clock.');
break;
case '!doom-show':
sendChat('Doomsday Clock', '/w gm Doomsday Clock says: '+doom_count());
break;
}
});
});
I bolded my additions and changes. Note: this is not how I would write this normally, but I'm just throwing it in here so you can see what was missing. You could take this now and place it in the API section and then you would have access to chat commands to set, start ,stop and show the clock. I have no idea if this works, but you should be able to build from here.