From a44494ab76113280220d8ab5d4069485508c82f1 Mon Sep 17 00:00:00 2001 From: "Aaron C. Meadows" Date: Sat, 2 May 2015 16:22:45 -0500 Subject: [PATCH 1/2] Squashed 'Torch/' changes from d4c0eb4..fa46e0f fa46e0f prod-Torch: Updated prod version of Torch at version 0.8.1. git-subtree-dir: Torch git-subtree-split: fa46e0fcc0249e935f2da907b21bb5de5fe7a0b5 --- Torch.js | 72 ++++++++++++++++++++++++++++++++++++++-------------- package.json | 2 +- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/Torch.js b/Torch.js index badf0d7bc5..ac9f1836d6 100644 --- a/Torch.js +++ b/Torch.js @@ -5,13 +5,14 @@ var Torch = Torch || (function() { 'use strict'; - var version = '0.8.0', - lastUpdate = 1430061737, - schemaVersion = 0.1, + var version = '0.8.1', + lastUpdate = 1430601526, + schemaVersion = 0.1, flickerURL = 'https://s3.amazonaws.com/files.d20.io/images/4277467/iQYjFOsYC5JsuOPUCI9RGA/thumb.png?1401938659', flickerPeriod = 400, flickerDeltaLocation = 2, flickerDeltaRadius = 0.1, + flickerDeltaAngle = 5, flickerInterval = false, ch = function (c) { @@ -49,7 +50,7 @@ var Torch = Torch || (function() { +'' +'Commands' +'
' - +'!torch ['+ch('<')+'Radius'+ch('>')+' ['+ch('<')+'Dim Start'+ch('>')+' ['+ch('<')+'All Players'+ch('>')+' ['+ch('<')+'Token ID'+ch('>')+' ... ]]]]' + +'!torch ['+ch('<')+'Radius'+ch('>')+' ['+ch('<')+'Dim Start'+ch('>')+' ['+ch('<')+'All Players'+ch('>')+' ['+ch('<')+'Token ID'+ch('>')+ch('|')+ch('<')+'--Angle'+ch('>')+' ... ]]]]' +'
' +'

Sets the light for the selected/supplied tokens. Only GMs can supply token ids to adjust.

' +'

Note: If you are using multiple '+ch('@')+ch('{')+'target'+ch('|')+'token_id'+ch('}')+' calls in a macro, and need to adjust light on fewer than the supplied number of arguments, simply select the same token several times. The duplicates will be removed.

' @@ -66,6 +67,9 @@ var Torch = Torch || (function() { +'
  • ' +''+ch('<')+'Token ID'+ch('>')+' '+ch('-')+' A Token ID, usually supplied with something like '+ch('@')+ch('{')+'target'+ch('|')+'Target 1'+ch('|')+'token_id'+ch('}')+'.' +'
  • ' + +'
  • ' + +''+ch('<')+'--Angle'+ch('>')+' '+ch('-')+' The angle of the light arc of the light. (Default: 360)' + +'
  • ' +'' +'
    ' +'!snuff ['+ch('<')+'Token ID'+ch('>')+' ... ]' @@ -78,7 +82,7 @@ var Torch = Torch || (function() { +' ' +'' +'
    ' - +'!flicker-on ['+ch('<')+'Radius'+ch('>')+' ['+ch('<')+'Dim Start'+ch('>')+' ['+ch('<')+'All Players'+ch('>')+' ['+ch('<')+'Token ID'+ch('>')+' ... ]]]]' + +'!flicker-on ['+ch('<')+'Radius'+ch('>')+' ['+ch('<')+'Dim Start'+ch('>')+' ['+ch('<')+'All Players'+ch('>')+' ['+ch('<')+'Token ID'+ch('>')+ch('|')+ch('<')+'--Angle'+ch('>')+' ... ]]]]' +'
    ' +'

    Behaves identically to !torch, save that it creates a flickering light.

    ' +'
    ' @@ -108,7 +112,7 @@ var Torch = Torch || (function() { +'' ); }, - setFlicker = function(o,r,d,p) { + setFlicker = function(o,r,d,p,a) { var found = _.findWhere(state.Torch.flickers, {parent: o.id}), fobj; @@ -122,7 +126,8 @@ var Torch = Torch || (function() { showplayers_aura1: false, light_radius: r, light_dimradius: d, - light_otherplayers: p + light_otherplayers: p, + light_angle: a }); } else { delete state.Torch.flickers[found.id]; @@ -141,7 +146,9 @@ var Torch = Torch || (function() { showplayers_aura1: false, light_radius: r, light_dimradius: d, - light_otherplayers: p + light_otherplayers: p, + light_angle: a + }); } else { delete state.Torch.flickers[found.id]; @@ -164,7 +171,9 @@ var Torch = Torch || (function() { layer: 'objects', light_radius: r, light_dimradius: d, - light_otherplayers: p + light_otherplayers: p, + light_angle: a + }); } toBack(fobj); @@ -174,7 +183,9 @@ var Torch = Torch || (function() { active: true, page: o.get('pageid'), light_radius: r, - light_dimradius: d + light_dimradius: d, + light_angle: a + }; }, @@ -189,6 +200,7 @@ var Torch = Torch || (function() { light_radius: '', ligh_dimradius: '', light_otherplayers: false, + light_angle: 360, showname: true, top: 70, left: 70, @@ -199,12 +211,12 @@ var Torch = Torch || (function() { }, handleInput = function(msg) { - var args, radius, dim_radius, other_players, page, obj, objs=[],who; + var args, radius, dim_radius, arc_angle=360, other_players, page, obj, objs=[],who; if (msg.type !== "api") { return; } - var who=getObj('player',msg.playerid).get('_displayname').split(' ')[0]; + who=getObj('player',msg.playerid).get('_displayname').split(' ')[0]; args = msg.content.split(" "); switch(args[0]) { @@ -221,6 +233,14 @@ var Torch = Torch || (function() { _.chain(args) .rest(4) .uniq() + .filter(function(a){ + var angle=a.match(/^--(\d+)$/)[1]; + if(angle){ + arc_angle=(Math.min(360,Math.max(0,angle))); + return false; + } + return true; + }) .map(function(t){ return getObj('graphic',t); }) @@ -229,7 +249,8 @@ var Torch = Torch || (function() { t.set({ light_radius: radius, light_dimradius: dim_radius, - light_otherplayers: other_players + light_otherplayers: other_players, + light_angle: arc_angle }); }); } @@ -238,7 +259,8 @@ var Torch = Torch || (function() { getObj(o._type,o._id).set({ light_radius: radius, light_dimradius: dim_radius, - light_otherplayers: other_players + light_otherplayers: other_players, + light_angle: arc_angle }); }); break; @@ -261,7 +283,8 @@ var Torch = Torch || (function() { t.set({ light_radius: '', light_dimradius: '', - light_otherplayers: false + light_otherplayers: false, + light_angle: 360 }); }); } @@ -269,7 +292,8 @@ var Torch = Torch || (function() { getObj(o._type,o._id).set({ light_radius: '', light_dimradius: '', - light_otherplayers: false + light_otherplayers: false, + light_angle: 360 }); }); break; @@ -331,6 +355,14 @@ var Torch = Torch || (function() { objs=_.chain(args) .rest(4) .uniq() + .filter(function(a){ + var angle=a.match(/^--(\d+)$/)[1]; + if(angle){ + arc_angle=(Math.min(360,Math.max(0,angle))); + return false; + } + return true; + }) .map(function(t){ return getObj('graphic',t); }) @@ -341,7 +373,7 @@ var Torch = Torch || (function() { _.each(_.union(objs,_.map(msg.selected,function (o) { return getObj(o._type,o._id); })), function(o){ - setFlicker(o, radius, dim_radius, other_players); + setFlicker(o, radius, dim_radius, other_players,arc_angle); }); break; @@ -379,7 +411,7 @@ var Torch = Torch || (function() { .each(function(fdata){ var o = getObj('graphic',fdata.parent), f = getObj('graphic',fdata.id), - dx, dy, dr; + dx, dy, dr, da; if(!o) { clearFlicker(fdata.id); @@ -390,10 +422,12 @@ var Torch = Torch || (function() { dx = randomInteger(2 * flickerDeltaLocation)-flickerDeltaLocation; dy = randomInteger(2 * flickerDeltaLocation)-flickerDeltaLocation; dr = randomInteger(2 * (fdata.light_radius*flickerDeltaRadius)) - (fdata.light_radius*flickerDeltaRadius); + da = randomInteger(2 * flickerDeltaAngle)-flickerDeltaAngle; f.set({ top: o.get('top')+dy, left: o.get('left')+dx, - light_radius: fdata.light_radius+dr + light_radius: fdata.light_radius+dr, + light_angle: (360 === fdata.light_angle ? 360 : Math.min(360,Math.max(fdata.light_angle+da,0))) }); } } diff --git a/package.json b/package.json index 1ea287f66f..f90a115bcc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Torch", - "version": "0.8.0", + "version": "0.8.1", "description": "A simple script for giving lights to tokens and turning off and on dynamic lighting.", "authors": "The Aaron", "roll20userid": "104025", From 5a47170f7f8abb00e39e2bc033a153ec85ab6010 Mon Sep 17 00:00:00 2001 From: "Aaron C. Meadows" Date: Sun, 3 May 2015 10:30:07 -0500 Subject: [PATCH 2/2] Squashed 'Torch/' changes from fa46e0f..ad61293 ad61293 prod-Torch: Updated prod version of Torch at version 0.8.2. git-subtree-dir: Torch git-subtree-split: ad61293cae8125db50229fced38f03d9b150d6d5 --- Torch.js | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Torch.js b/Torch.js index ac9f1836d6..150f455e5d 100644 --- a/Torch.js +++ b/Torch.js @@ -5,8 +5,8 @@ var Torch = Torch || (function() { 'use strict'; - var version = '0.8.1', - lastUpdate = 1430601526, + var version = '0.8.2', + lastUpdate = 1430666803, schemaVersion = 0.1, flickerURL = 'https://s3.amazonaws.com/files.d20.io/images/4277467/iQYjFOsYC5JsuOPUCI9RGA/thumb.png?1401938659', flickerPeriod = 400, @@ -234,9 +234,9 @@ var Torch = Torch || (function() { .rest(4) .uniq() .filter(function(a){ - var angle=a.match(/^--(\d+)$/)[1]; + var angle=a.match(/^--(\d+)$/); if(angle){ - arc_angle=(Math.min(360,Math.max(0,angle))); + arc_angle=(Math.min(360,Math.max(0,angle[1]))); return false; } return true; @@ -356,9 +356,9 @@ var Torch = Torch || (function() { .rest(4) .uniq() .filter(function(a){ - var angle=a.match(/^--(\d+)$/)[1]; + var angle=a.match(/^--(\d+)$/); if(angle){ - arc_angle=(Math.min(360,Math.max(0,angle))); + arc_angle=(Math.min(360,Math.max(0,angle[1]))); return false; } return true; diff --git a/package.json b/package.json index f90a115bcc..677df8e5ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Torch", - "version": "0.8.1", + "version": "0.8.2", "description": "A simple script for giving lights to tokens and turning off and on dynamic lighting.", "authors": "The Aaron", "roll20userid": "104025",