// By: Kastion
// Contact: https://app.roll20.net/users/3173313/kastion
var moveLighting = moveLighting || (function(){
'use strict';
var showHelp = function() {
sendChat('Move Lighting Script',
'/w gm '+
'
'+
'
'+
'
'+
'
Allows the GM to move what layer a lighting path is on.
'+
'
'+
'
Commands'+
'
!movelight [layer] [ID]'+
'
'+
'Valid Layer Options Are: map, objects, gmlayer, walls'+
'
'+
'
'
);
},
handleInput = function(msg) {
if ( "api" !== msg.type || !playerIsGM(msg.playerid) ) {
return;
}
let parts = msg.content.split(/\s+--\s+/);
let args = parts[0].split(/\s+/);
switch(args[0]) {
case '!movelight': {
var valid_layer = 0, new_layer = args[1];
switch (new_layer)
{
case "gmlayer":
case "walls":
case "objects":
case "map":
valid_layer = 1;
break;
}
if (valid_layer == 1)
{
var path_obj = findObjs({_type: "path", _id: args[2]})[0];
if (path_obj)
{
path_obj.set("layer", new_layer);
} else {
sendChat('Move Lighting Script', '/w gm No path object found with that ID.');
}
} else {
sendChat('Move Lighting Script', '/w gm Invalid Layer Specified.');
showHelp();
}
break;
}
}
},
checkInstall = function()
{
var script_version = "0.1.4";
if( ! state.moveLighting ) {
state.moveLighting = {
version: script_version,
};
}
if (state.moveLighting.version != script_version)
state.moveLighting.version = script_version;
log("-=> Move Lighting Script v"+state.moveLighting.version+" Initialized <=-")
},
registerEventHandlers = function() {
on('chat:message', handleInput);
};
return {
CheckInstall: checkInstall,
RegisterEventHandlers: registerEventHandlers
};
}());
on("ready", function() {
'use strict';
moveLighting.CheckInstall();
moveLighting.RegisterEventHandlers();
});