Let's say I want to create an effect of "flickering light" that makes the whole map dark for a second and back again, to be dark once more. In some kind of loop. The question is how do I do this? It must be not only possible when tokens are on the page (dungeon), but also where there's nothing (just a picture). I would guess something with Fog of War? Or make a giant black token (or painting)? Maybe someone already did this? EDIT: Done. Macro : !suddendark ?{ms|2000} ?{flicker?|Yes,true|No,false} ?{times?|10} Explanation : 1st Argument is interval in miliseconds. 2nd Argument is if it's going to flicker (times should be also set) or only one time darkness 3rd Argument is how many times it will flick on/off. Code : var suddenDarkness = false;
function SuddenDarkness(interval, flicker, times)
{
if (interval == null) interval = 200;
if (flicker == "false") flicker = false;
else flicker = true;
if (times == null) times = 0;
if (times % 2 == 1) times = times + 1;
if (suddenDarkness == false)
{
var currentPage = findObjs({
_id: Campaign().get("playerpageid"),
_type: "page"
})[0];
currentPage.set("showlighting", true);
currentPage.set("lightglobalillum", false);
if (flicker == true)
{
var i = 0;
var inter = setInterval(function()
{
currentPage.set("lightglobalillum", !currentPage.get("lightglobalillum"))
i = i + 1;
if (i == times)
{
currentPage.set("lightglobalillum", true);
currentPage.set("showlighting", false);
clearInterval(inter);
}
}, interval)
}
else
{
setTimeout(function()
{
currentPage.set("lightglobalillum", true)
}, interval);
}
suddenDarkness = false;
}
};
on("chat:message", function(msg) {
if ( msg.type != 'api' ) return;
var cmd = msg.content.toLowerCase().split(' ');
if ( cmd[0] == "!suddendark" )
{
SuddenDarkness(cmd[1], cmd[2], cmd[3]);
}
});