Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] Flickering Lights for crashed space ship

1504621922

Edited 1504646638
v2.0 Added support to toggle the token between object and gmlayer. Allows the light to have a physical form such as lightning. Made this for my Pathfinder Iron God's game. Someone might find it useful. Leigh //============================================================================================== // // FlickeringLights.js (v2.0) // //&nbsp; Simple script that takes all the graphic tokens named 'FlickeringLight' on the currently // active PLAYERS PAGE and causes them to blink on/off. The blinking is done by toggling the // 'All Players See Light' on the token (Edit Token-&gt;Advanced-&gt;Emits Light). // //&nbsp; The token can also be toggled between the object and and gmlayer if 'Aura 1 Square' is // checked ('Edit Token-&gt;Basic-&gt;Aura 1 Square'). I used this to make my lightning image flash // with the ligh. // //&nbsp; How often the light blinks can be configured using 'Bar 1' (Edit Token-&gt;Basic-&gt;Bar 1). The // value is considered a percentage where 90 would mean that the light will be on 90% of the // time. The default is 50 if no value is found in 'Bar 1'. // //&nbsp; The rate of how often all the FlickeringLights are updated can be changed using the speed // command followed milliseconds. So if you set the speed to say 5000, then all the lights will // have a CHANCE to be toggled every 5 seconds. I use it with a very fast update like 100ms and // have most of the lights use a high percentage in 'Bar 1' like 90. This makes the all the // lights stay on most of the time and blink off for a very short period of time to simulate // something like a crashed spaceship lighting. // // Chat Commands: // // !FlickeringLights help // !FlickeringLights on // !FlickeringLights off // !FlickeringLights speed [ms] // !FlickeringLights enable [group] // !FlickeringLights disable [group] // // // Based on the Jack T FlicheringLights script posted on the API forum. //&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;(<a href="https://app.roll20.net/forum/post/1366850/flickering-lights" rel="nofollow">https://app.roll20.net/forum/post/1366850/flickering-lights</a>) // // Used help_menu from Steve Kootz's DynamicLightHelper //&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;(<a href="https://github.com/Roll20/roll20-api-scripts/tree/master/DynamicLightHelper" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/tree/master/DynamicLightHelper</a>) //============================================================================================== var FlickeringLights&nbsp;&nbsp; &nbsp;= { &nbsp;&nbsp;&nbsp; SCRIPT_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : "FlickeringLight.js", &nbsp;&nbsp; &nbsp;CHAT_COMMAND&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;: "!FlickeringLights ", &nbsp;&nbsp;&nbsp; TOKEN_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : "FLight", &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;IntervalMS&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;: 200, &nbsp;&nbsp; &nbsp;Timer&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;: null, &nbsp;&nbsp;&nbsp; ChatTemplate&nbsp;&nbsp; &nbsp;: _.template( "/w GM &lt;div style=\"padding:1px 3px; border: 1px solid &lt;%=border%&gt;; background: &lt;%=background%&gt;; color: &lt;%=color%&gt;; font-size: 80%;\"&gt;&lt;%=text%&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;" ), &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;onUpdate : function() &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var&nbsp;&nbsp; &nbsp;tokens = findObjs( &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_pageid:&nbsp;&nbsp; &nbsp;Campaign().get( "playerpageid" ), &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_type:&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"graphic", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_subtype:&nbsp;&nbsp; &nbsp;"token", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for( var index = 0; index &lt; tokens.length; ++index ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; var token&nbsp;&nbsp; = tokens[index]; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; var name&nbsp;&nbsp;&nbsp; = token.get( "name" ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// Is it a FlickeringLight? &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; if ( name.indexOf( FlickeringLights.TOKEN_NAME ) != 0 ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Is disabled? &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( token.get( "aura2_square" ) == true ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Percent chance on. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; var chanceOn&nbsp;&nbsp;&nbsp; = token.get( "bar1_value" ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; if ( chanceOn.length == 0 ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chanceOn = 50; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var&nbsp;&nbsp; &nbsp;bOn&nbsp;&nbsp; &nbsp;= ((Math.random() * 100.0) &lt; chanceOn) ? true : false; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;token.set( "light_otherplayers", bOn ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; if ( token.get( "aura1_square" ) == true ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( bOn == true ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;token.set( "layer", "objects" ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; token.set( "layer", "gmlayer" ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;}, &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;onDisableAll&nbsp; : function( groupName, bDisable ) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var&nbsp;&nbsp; &nbsp;tokens = findObjs( &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_pageid:&nbsp;&nbsp; &nbsp;Campaign().get( "playerpageid" ), &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_type:&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"graphic", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;_subtype:&nbsp;&nbsp; &nbsp;"token", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for( var index = 0; index &lt; tokens.length; ++index ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; var token&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = tokens[index]; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; var name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = token.get( "name" ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; var idxTokenName&nbsp;&nbsp;&nbsp; = name.indexOf( FlickeringLights.TOKEN_NAME ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; if ( idxTokenName == -1 ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; var idxGroupName&nbsp;&nbsp;&nbsp; = name.indexOf( groupName, idxTokenName + FlickeringLights.TOKEN_NAME.length ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var tokenGroupName&nbsp; = name.slice( idxGroupName ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; if ( tokenGroupName == groupName ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;log( "Disable [" + tokenGroupName + "]: " + bDisable ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;token.set( "light_otherplayers", (bDisable == false) ? true : false ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; token.set( "aura2_square", bDisable ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;}, &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;start : function() &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;clearInterval( FlickeringLights.Timer ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FlickeringLights.Timer&nbsp;&nbsp; &nbsp;= setInterval( function() { FlickeringLights.onUpdate(); }, FlickeringLights.IntervalMS ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;log( "StartFlickering()" ); &nbsp;&nbsp; &nbsp;}, &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;stop : function() &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( FlickeringLights.Timer ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;clearInterval( FlickeringLights.Timer ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FlickeringLights.Timer&nbsp;&nbsp; &nbsp;= null; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;log( "StopFlickering" ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;}, &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp;&nbsp; showHelp&nbsp; :&nbsp; function () &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendChat( FlickeringLights.SCRIPT_NAME, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FlickeringLights.ChatTemplate( &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; border: "#00529B", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; background: "#BDE5F8", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; color: "#00529B", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text: "&lt;b&gt;Help:&lt;/b&gt;&lt;br&gt;" + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;dl&gt;" + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;dt&gt;on&lt;/dt&gt;&lt;dd&gt;Start updating lights&lt;/dd&gt;" + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;dt&gt;off&lt;/dt&gt;&lt;dd&gt;Stop updating lighting&lt;/dd&gt;" + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;dt&gt;speed [ms]&lt;/dt&gt;&lt;dd&gt;Change the rate of update in milliseconds&lt;/dd&gt;" + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;dt&gt;enable [group]&lt;/dt&gt;&lt;dd&gt;Start flickering tokens named '" + FlickeringLights.TOKEN_NAME + "' the group name.&lt;/dd&gt;" + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;dt&gt;disable [group]&lt;/dt&gt;&lt;dd&gt;Stop&nbsp; flickering tokens named '" + FlickeringLights.TOKEN_NAME + "' the group name.&lt;/dd&gt;" + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;/dl&gt; " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } )); &nbsp;&nbsp;&nbsp; }, &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;//============================================================================================== &nbsp;&nbsp; &nbsp;onApiCommand : function( command ) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;log( "OnApiCommand: " + command ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( !command.indexOf( "help" ) ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; FlickeringLights.showHelp(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( !command.indexOf( "on" ) ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FlickeringLights.start(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( !command.indexOf( "off" ) ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FlickeringLights.stop(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( !command.indexOf( "speed" ) ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var speed&nbsp;&nbsp; = command.slice( 6 ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FlickeringLights.IntervalMS&nbsp; = Number( speed ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FlickeringLights.start(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( !command.indexOf( "enable" ) ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var groupName&nbsp;&nbsp; = command.slice( 7 ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FlickeringLights.onDisableAll( groupName, false ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( !command.indexOf( "disable" ) ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var groupName&nbsp;&nbsp; = command.slice( 8 ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FlickeringLights.onDisableAll( groupName, true ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;}, }; //================================================================================================== //================================================================================================== on( "chat:message", function( msg ) { &nbsp;&nbsp; &nbsp;try &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;switch( msg.type ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;case "api": &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var&nbsp;&nbsp; &nbsp;idxCmd&nbsp;&nbsp; &nbsp;= msg.content.indexOf( FlickeringLights.CHAT_COMMAND ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( idxCmd != -1 ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FlickeringLights.onApiCommand( msg.content.slice( idxCmd + FlickeringLights.CHAT_COMMAND.length ) ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;break; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;catch( err ) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sendChat( "*** FlickeringLights Exception: ", err.message ); &nbsp;&nbsp; &nbsp;} } ); log( "FlickeringLights COMPILED [" + (new Date()) + "]");
1504622204

Edited 1504622211
The Aaron
Pro
API Scripter
Nice addition!
1504648917
Gold
Forum Champion
Cool idea! I want to use it. One of my characters arrived in the world on a crashed space ship so maybe I can make a map of the crash site and light it with this script.