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

Need help updating old Flight script

I use a script called Flight.js all the time in my games. Like ... constantly. I am shocked more people don't. Info can be found here . Since the last update, this script does not work right ... it reverses the numbers. If I type "150" in the input box, I get status markers that read 051. I do not have the programming skills to fix this problem. Can anyone help? Here is the script I am using. Please note, I added a "dig" option for burrowing monsters that has worked for months, so I don't think its the problem. 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... */ dig: function(args, msg) { var depth = parseInt(args[0]) || 0; markStatus('aura', depth, msg.selected); }, 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 &amp;'+'lt;number&amp;'+'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) =&gt; o._type !== 'graphic'); if (!selected.length) return; if(num) { markerStr = _.chain(num.toString().split('')) .map((d) =&gt; `${marker}@${d}`) .value() .reverse() .join(','); } _.each(selected, (obj) =&gt; { token = getObj('graphic', obj._id); if (token &amp;&amp; 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 &amp;&amp; arg0.length &gt; 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(); }); Thanks in advance! P.S. If there is a better way to handle flight (and burrowing), please let me know.
1549658261

Edited 1549659220
GiGs
Pro
Sheet Author
API Scripter
As a test try changing this section: markerStr = _.chain(num.toString().split('')) .map((d) =&gt; `${marker}@${d}`) .value() .reverse() .join(','); to&nbsp; markerStr = _.chain(num.toString().split('')) .map((d) =&gt; `${marker}@${d}`) .value() .join(','); TokenMod can probably handle this well btw.
1549661281
The Aaron
Roll20 Production Team
API Scripter
I had to fix the same ordering bug in TokenMod.&nbsp; The new order is better than the old one, but it does mean that flight.js and TokenMod needed updating.&nbsp; I'm working on adjusting TokenMod to work with multi-digit number directly, right now you need to manipulate them individually.&nbsp; When I get that done, TokenMod would be an easy alternative to fly.
The Aaron said: I had to fix the same ordering bug in TokenMod.&nbsp; The new order is better than the old one, but it does mean that flight.js and TokenMod needed updating.&nbsp; I'm working on adjusting TokenMod to work with multi-digit number directly, right now you need to manipulate them individually.&nbsp; When I get that done, TokenMod would be an easy alternative to fly. I use TokenMod all the time! It just never occurred to me to use it for this because I had Flight API. Using TokenMod is a great solution! TokenMod is a brilliant bit of programming ... thank you so much for your fine work.
I wrote a new one because the old one wasn't working:&nbsp; <a href="https://github.com/blawson69/Flying" rel="nofollow">https://github.com/blawson69/Flying</a>