Flight script It wouldn't be too difficult to duplicate the !fly command for other relevant bits of information, although I don't know how using multiple statusmarkers like that would interact. Also, as demonstrated by the screenshot in the README, a large number of digits can make the statusmarkers flow out to the left of the token very quickly, so I don't know if that solution is necessarily viable for you. Edit: here's a new version that would be easier to extend var bshields = bshields || {};
bshields.flight = (function() {
'use strict';
var version = 3.4,
commands = {
fly: function(args, msg) {
var height = parseInt(args[0]) || 0;
markStatus('fluffy-wing', height, msg.selected);
},
/**
* To add new command, use this template:
commandname: function(args, msg) {
var num = parseInt(args[0]) || 0;
markStatus('statusmarker-name', num, msg.selected);
},
* Statusmarker names are listed at <a href="https://wiki.roll20.net/API:Objects#Graphic_.28Token.2FMap.2FCard.2FEtc..29" rel="nofollow">https://wiki.roll20.net/API:Objects#Graphic_.28Token.2FMap.2FCard.2FEtc..29</a>
* commandname should be ALL LOWER-CASE and CANNOT contain spaces. If commandname includes anything other than a-z0-9_
* or if it begins with a number, it must be enclosed in quotes, eg:
'command-name': function...
*/
help: function(command, args, msg) {
if (_.isFunction(commands[`help_${command}`])) {
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.');
}
};
function markStatus(marker, num, selected) {
var markerStr = '',
token, markers;
if (!selected) return;
selected = _.reject(selected, (o) => o._type !== 'graphic');
if (!selected.length) return;
if(num) {
markerStr = _.chain(num.toString().split(''))
.map((d) => `${marker}@${d}`)
.value()
.reverse()
.join(',');
}
_.each(selected, (obj) => {
token = getObj('graphic', obj._id);
if (token && token.get('subtype') === 'token') {
token.set(`status_${marker}`, false);
markers = token.get('statusmarkers');
markers = markers ? markers.trim() : '';
markers += (markers.length ? ',' : '') + markerStr;
token.set('statusmarkers', markers);
}
});
}
function handleInput(msg) {
var isApi = msg.type === 'api',
args = msg.content.trim().splitArgs(),
command, arg0, isHelp;
if (isApi) {
command = args.shift().substring(1).toLowerCase();
arg0 = args.shift() || '';
isHelp = arg0.toLowerCase() === 'help' || arg0.toLowerCase() === 'h' || command === 'help';
if (!isHelp) {
if (arg0 && arg0.length > 0) {
args.unshift(arg0);
}
if (_.isFunction(commands[command])) {
commands[command](args, msg);
}
} else if (_.isFunction(commands.help)) {
commands.help(command === 'help' ? arg0 : command, args, msg);
}
} else if (_.isFunction(commands['msg_' + msg.type])) {
commands['msg_' + msg.type](args, msg);
}
}
function registerEventHandlers() {
on('chat:message', handleInput);
}
return {
registerEventHandlers: registerEventHandlers
};
}());
on('ready', function() {
'use strict';
bshields.flight.registerEventHandlers();
});
As you can see here, adding a new command with functionality just like !fly is basically a matter of copying lines 7-10, changing "fly" to what you want the new command to be, and changing "fluffy-wing" to what you want the new statusmarker to be.