Skip to content
Open
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
108 changes: 108 additions & 0 deletions moveLighting/0.1.5/moveLighting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// 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 '+
'<div style="border: 1px solid black; background-color: white; padding: 3px 3px;">'+
'<div style="font-weight: bold; border-bottom: 1px solid black;font-size: 130%;">'+
'moveLighting'+
'<div style="clear: both"></div>'+
'</div>'+
'<div style="padding-left:10px;margin-bottom:3px;">'+
'<p>Allows the GM to move what layer a lighting path is on.</p>'+
'</div>'+
'<b>Commands</b>'+
'<div style="padding-left:10px;"><b><span style="font-family: serif;">!movelight [layer] [ID]</span></b>'+
'<div style="padding-left: 10px;padding-right:20px; font-size:12px;">'+
'On Jumpgate Games, Valid Layer Options Are: map, objects, gmlayer, walls, foreground'+
'</div>'+
'<div style="padding-left: 10px;padding-right:20px; font-size:12px;">'+
'On Legacy Games, Valid Layer Options Are: map, objects, gmlayer, walls'+
'</div>'+
'</div>'
);
},

handleInput = function(msg) {

if ( "api" !== msg.type || !playerIsGM(msg.playerid) ) {
return;
}

let parts = msg.content.split(/\s+--\s+/);
let args = parts[0].split(/\s+/);
const isJumpgate = () => ['jumpgate'].includes(Campaign().get('release'));
var obj_type,valid_layers;

switch(args[0]) {
case '!movelight': {
var new_layer = args[1];

if (isJumpgate()){
obj_type = "pathv2";
valid_layers = ["gmlayer","walls","objects","map","foreground"];
}

else{
obj_type = "path";
valid_layers = ["gmlayer","walls","objects","map"];
}

if (valid_layers.includes(new_layer))
{
var path_obj = findObjs({_type: obj_type, _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.5";
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();
});
10 changes: 6 additions & 4 deletions moveLighting/script.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"name": "Move Lighting",
"script": "moveLighting.js",
"version": "0.1.4",
"previousversions": [],
"description": "# Page FX\n\n_v0.1.4 Updates_\n\nUse the command !movelight with the parameters of:\n\n1) the layer to move to and\n\n2) the ID of the dynamic lighting path object\n\nExample: !movelight gmlayer -LDSsme9FmMDFmf",
"version": "0.1.5",
"previousversions": ["0.1.4"],
"description": "Move Lighting v0.1.5 adds support for Jumpgate lighting and the foreground layer.\n\nUse the command !movelight with the parameters of:\n\n1) the layer to move to and\n\n2) the ID of the dynamic lighting path object\n\nExample: !movelight gmlayer -LDSsme9FmMDFmf",
"authors": "Luke LeClair a.k.a Kastion",
"roll20userid": 3173313,
"useroptions": [],
"dependencies": [],
"modifies": {
"graphic:bar1_value": "read"
"path": "read",
"pathv2": "read",
"campaign.release":"read"
},
"conflicts": []
}
Loading