diff --git a/TokenMod/TokenMod.js b/TokenMod/TokenMod.js index 711efe0778..26870d1c1b 100644 --- a/TokenMod/TokenMod.js +++ b/TokenMod/TokenMod.js @@ -5,7 +5,8 @@ var TokenMod = TokenMod || (function() { 'use strict'; - var version = 0.7, + var version = '0.8.1', + lastUpdate = 1427607758, schemaVersion = 0.1, fields = { @@ -45,6 +46,7 @@ var TokenMod = TokenMod || (function() { // distance light_radius: {type: 'numberBlank'}, light_dimradius: {type: 'numberBlank'}, + light_multiplier: {type: 'numberBlank'}, aura1_radius: {type: 'numberBlank'}, aura2_radius: {type: 'numberBlank'}, @@ -59,6 +61,7 @@ var TokenMod = TokenMod || (function() { bar2: {type: 'text'}, bar3: {type: 'text'}, + // colors aura1_color: {type: 'color'}, aura2_color: {type: 'color'}, @@ -125,6 +128,22 @@ var TokenMod = TokenMod || (function() { return ''; }, + getConfigOption_PlayersCanIDs = function() { + var text = ( state.TokenMod.playersCanUse_ids + ? 'ON' + : 'OFF' + ); + return '
' + +'Players can IDs is currently ' + +text + +'' + +'Toggle' + +'' + +'
'; + + }, + + showHelp = function(id) { var who=getObj('player',id).get('_displayname').split(' ')[0]; sendChat('', @@ -169,7 +188,7 @@ var TokenMod = TokenMod || (function() { +'' +'' - +'Configuration' + +'Specification' +'
' +'

--ids takes token ids to operate on, separated by spaces.

' +'
'
@@ -179,23 +198,6 @@ var TokenMod = TokenMod || (function() {
 			+'
'
 				+'!token-mod --ids @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} --on showname showplayers_name'
 			+'
' - - +'

--config takes option value pairs, separated by | characters.

' - +'
'
-				+'!token-mod --config option|value option|value'
-			+'
' - +'

There is currently one configuration option:

' - - +'
' - +'
    ' - +'
  • ' - +'
    ' - +( state.TokenMod.playersCanUse_ids ? 'ON' : 'OFF' ) - +'
    ' - +'players-can-ids '+ch('-')+' Determines if players can use --ids. Specifying a value which is true allows players to use --ids. Omitting a value flips the current setting.' - +'
  • ' - +'
' - +'
' +'
' +'Booleans' @@ -280,6 +282,7 @@ var TokenMod = TokenMod || (function() { +'

Available Numbers or Blank Properties:

' +'
light_radius
' +'
light_dimradius
' + +'
light_multiplier
' +'
aura1_radius
' +'
aura2_radius
' +'
'+ch(' ')+'
' @@ -533,11 +536,35 @@ var TokenMod = TokenMod || (function() { +'' +'' + +'Configuration' + +'
' + +'

--config takes option value pairs, separated by | characters.

' + +'
'
+				+'!token-mod --config option|value option|value'
+			+'
' + +'

There is currently one configuration option:

' + + +'
' + +'' + +'
' + +getConfigOption_PlayersCanIDs() + +'
' + + +'' +'' ); }, + + getRelativeChange = function(current,update) { var cnum = current && (_.isNumber(current) @@ -826,8 +853,9 @@ var TokenMod = TokenMod || (function() { case 'light_radius': case 'light_dimradius': - case 'aura1_radius': + case 'light_multiplier': case 'aura2_radius': + case 'aura1_radius': delta=getRelativeChange(token.get(k),f[0]); if(_.isNumber(delta) || '' === delta) { mods[k]=delta; @@ -851,37 +879,49 @@ var TokenMod = TokenMod || (function() { break; } }); - mods.statusmarkers=_.map(current,function(v,k){ return ('dead' === k) ? (k) : (k+'@'+v);}).join(','); + mods.statusmarkers=_.map(current,function(v,k){ return ('dead' === k ? k : k+'@'+v); }).join(','); token.set(mods); }, handleConfig = function(config, id) { var args, cmd, who=getObj('player',id).get('_displayname').split(' ')[0]; - while(config.length) { - args=config.shift().split(/\|/); - cmd=args.shift(); - switch(cmd) { - case 'players-can-ids': - if(args.length) { - state.TokenMod.playersCanUse_ids = filters.isTruthyArgument(args.shift()); - } else { - state.TokenMod.playersCanUse_ids = !state.TokenMod.playersCanUse_ids; - } - sendChat('', '/w '+who+'
' - + ( state.TokenMod.playersCanUse_ids ? 'Players can now use --ids to specify targets to change.' : 'Players cannot use --ids.' ) - +'
' - ); - break; - default: - sendChat('', '/w '+who+'
' - +'Error: ' - +'No configuration setting for ['+cmd+']' - +'
' - ); - break; - } - } + if(config.length) { + while(config.length) { + args=config.shift().split(/\|/); + cmd=args.shift(); + switch(cmd) { + case 'players-can-ids': + if(args.length) { + state.TokenMod.playersCanUse_ids = filters.isTruthyArgument(args.shift()); + } else { + state.TokenMod.playersCanUse_ids = !state.TokenMod.playersCanUse_ids; + } + sendChat('','/w '+who+' ' + +'
' + +getConfigOption_PlayersCanIDs() + +'
' + ); + break; + default: + sendChat('', '/w '+who+'
' + +'Error: ' + +'No configuration setting for ['+cmd+']' + +'
' + ); + break; + } + } + } else { + sendChat('','/w '+who+' ' + +'
' + +'
' + +'TokenMod v'+version + +'
' + +getConfigOption_PlayersCanIDs() + +'
' + ); + } }, handleInput = function(msg_orig) { @@ -910,7 +950,11 @@ var TokenMod = TokenMod || (function() { .value(); } - args = msg.content.split(/\s+--/); + args = msg.content + .replace(/\n/g, ' ') + .replace(/(\{\{(.*?)\}\})/g," $2 ") + .split(/\s+--/); + switch(args.shift()) { case '!token-mod': @@ -922,7 +966,7 @@ var TokenMod = TokenMod || (function() { return; case 'config': - if(isGM(msg.playerid)) { + if(playerIsGM(msg.playerid)) { handleConfig(cmds,msg.playerid); } return; @@ -951,7 +995,7 @@ var TokenMod = TokenMod || (function() { modlist.off=_.difference(modlist.off,modlist.on); modlist.flip=_.difference(modlist.flip,modlist.on,modlist.off); - if(isGM(msg.playerid) || state.TokenMod.playersCanUse_ids ) { + if(playerIsGM(msg.playerid) || state.TokenMod.playersCanUse_ids ) { _.chain(ids) .uniq() .map(function(t){ @@ -972,6 +1016,8 @@ var TokenMod = TokenMod || (function() { }, checkInstall = function() { + log('-=> TokenMod v'+version+' <=- ['+(new Date(lastUpdate*1000))+']'); + if( ! _.has(state,'TokenMod') || state.TokenMod.version !== schemaVersion) { state.TokenMod = { version: schemaVersion, @@ -993,13 +1039,6 @@ var TokenMod = TokenMod || (function() { on("ready",function(){ 'use strict'; - if("undefined" !== typeof isGM && _.isFunction(isGM)) { - TokenMod.CheckInstall(); - TokenMod.RegisterEventHandlers(); - } else { - log('--------------------------------------------------------------'); - log('TokenMod requires the isGM module to work.'); - log('isGM GIST: https://gist.github.com/shdwjk/8d5bb062abab18463625'); - log('--------------------------------------------------------------'); - } + TokenMod.CheckInstall(); + TokenMod.RegisterEventHandlers(); }); diff --git a/TokenMod/package.json b/TokenMod/package.json index 55b726f0bd..60b602c8d5 100644 --- a/TokenMod/package.json +++ b/TokenMod/package.json @@ -1,24 +1,21 @@ { - "name": "TokenMod", - "version": "0.7", - "description": "An interface to adjusting properties of a token from a macro or the chat area.", - "authors": "The Aaron", - "roll20userid": "104025", - "dependencies": { - "isGMModule": "0.x" - }, - "modifies": { - "state.TokenMod": "read,write", - "attribute.characterid": "read", - "attribute.current": "read", - "attribute.id": "read", - "attribute.max": "read", - "attribute.name": "read", - "attribute.type": "read", - "character.archived": "read", - "character.name": "read", - "graphic.*": "read,write" - }, - "conflicts": [ - ] + "name": "TokenMod", + "version": "0.8.1", + "description": "An interface to adjusting properties of a token from a macro or the chat area.", + "authors": "The Aaron", + "roll20userid": "104025", + "dependencies": [], + "modifies": { + "state.TokenMod": "read,write", + "attribute.characterid": "read", + "attribute.current": "read", + "attribute.id": "read", + "attribute.max": "read", + "attribute.name": "read", + "attribute.type": "read", + "character.archived": "read", + "character.name": "read", + "graphic.*": "read,write" + }, + "conflicts": [] }