Skip to content
Merged
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
File renamed without changes.
46 changes: 24 additions & 22 deletions Flight/Flight.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,43 @@ var bshields = bshields || {};
bshields.flight = (function() {
'use strict';

var version = 3.1,
var version = 3.2,
commands = {
fly: function(args, msg) {
var selected = msg.selected,
height = parseInt(args[0], 10) || 0;
height = parseInt(args[0], 10) || 0,
wings = '';

if(height) {
wings = _.chain(height.toString().split(''))
.map(function(d){
return 'fluffy-wing@'+d;
})
.value()
.reverse()
.join(',');
}

if (!selected) { return; }
_.each(selected, function(obj) {
var token = getObj('graphic', obj._id),
wings = '',
digit, markers;
markers;

if (obj._type !== 'graphic' || !token || token.get('subtype') !== 'token') { return; }
token.set('status_fluffy-wing', false);
while (height > 0) {
// Iterate over digits, from ones on up
digit = height / 10;
digit -= Math.floor(digit);
digit = Math.round(digit * 10);

// Shift height
height = Math.floor(height / 10);

wings += 'fluffy-wing@' + digit + ',';
}

if (wings.length > 0) {
wings = wings.substring(0, wings.length - 1);
}

markers = token.get('statusmarkers');
if (markers !== '') markers += ',';
markers += wings;
markers += ( markers ? ',' : '' ) + wings;
token.set('statusmarkers', markers);
});
},
help: function(command, args, msg) {
if (_.isFunction(commands['help_' + command]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a closing parentheses

commands['help_' + command](args, msg);
}
},
help_fly: function(args, msg) {
sendChat('Flight v'+version, 'Specify !fly &'+'lt;number&'+'gt; to add that number as wings on the selected token.' );
}
};

Expand All @@ -50,7 +52,7 @@ bshields.flight = (function() {

if (isApi) {
command = args.shift().substring(1).toLowerCase();
arg0 = args.shift();
arg0 = args.shift() || '';
isHelp = arg0.toLowerCase() === 'help' || arg0.toLowerCase() === 'h';

if (!isHelp) {
Expand Down
4 changes: 2 additions & 2 deletions Flight/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Flight",
"version": "3.1",
"description": "Adds 'fluffy-wings' status icon to selected token to represent some hieght.",
"version": "3.2",
"description": "Adds 'fluffy-wings' status icon to selected token to represent some height.",
"authors": "Brian Shields",
"roll20userid": "235259",
"dependencies": {
Expand Down