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

{Script} groupinitiative - GURPS: decimal and 0 value attribute stats for initiative

1479202610

Edited 1479202901
Mike W.
Pro
Sheet Author
The Aaron Love your script however I must be doing something wrong in my selections as it always round the initiative number instead of displaying the decimal number. I amusing GURPS and that system does not have an initiative die roll, its is strictly a stat on the character sheet, HOWEVER that stat could be a decimal like 6.25 or 4.75 as well as 5.00 I ran the command and it picks the correct stat and value but drops all decimals when displayed in the turn order. Is this the normal way? If not, could that be an option to display the full decimal value? Also could you have the following 2 options made available;? An option to ignore any token selected that has a stat of 0 or null when determining initiative? An option to select all tokens on the map by default? When combined above, it will select all tokens but only report those with an initiative above 0 (based on their stat). Thank you script god (Big God name has already been taken) Mike
1479210841
The Aaron
Pro
API Scripter
Hmm. I'll have to test the decimal issue. (Was thinking there was a setting for decimal places in the config.) Adding those others is certainly possible. That script is fairly complicated and the rules system desperately needs a rewrite. It might be easier in the short term for me to write you a simple script that just does the initiate like you stated in one go. 
1479211503

Edited 1479212235
Mike W.
Pro
Sheet Author
Well it does bring over the integer value of the stat but not the decimal number. The decimal setting in the config does not seem to do anything that I can understand. For the select all tokens and skipping those with values of null or 0, that would be a nice touch in deed but I would hate for you to make a script just for me. Problem is updates for it in the future, you would have to maintain 2 pieces of code, I would not like to burden you with that..
1479213377
The Aaron
Pro
API Scripter
Right, it wouldn't be a maintained script, just a little 15-20 line snippet tailored exactly to your setup.  Probably wouldn't require any maintenance provided your requirements didn't change. =D I took a quick peek at GroupInit and I don't see where the decimal would get dropped.  I'll have to setup something like what you have and try to track it down with some logging.
1479214170
Mike W.
Pro
Sheet Author
Ok I am using GURPS sheet #2. The attribute is named Speed. That value is #.##, players can enter a whole number like 5 or 5.00 or they may have a Speed of 5.25 or 5.50 or 4.75, etc. (you get the idea I hope). I know I read somewhere that there is a command to select all tokens on the desktop, I just cannot remember what that was. So that just leaves those with a Speed of 0 or null. Take you time. This should never have to be changed.
1479216633

Edited 1479216644
The Aaron
Pro
API Scripter
Give this a try: I didn't know what direction you sorted in, so I assumed highest to lowest (if that's not right, just change sortDirection to 1). Run the command: !gurps-init If you have tokens selected, the ones that qualify will become the initiative order.  If you don't have any selected, it will build the initiative order off all the qualifying tokens on the current page that represent a character and are on the objects or GM layer. on('ready',function(){     'use strict';     var initAttr = 'speed',         sortDirection = -1;     on('chat:message',function(msg){         if('api' === msg.type && msg.content.match(/^!gurps-init/) && playerIsGM(msg.playerid) ){              let pageid=getObj('player',msg.playerid).get('lastpage'),                 selectedIDs = _.pluck(msg.selected,'_id');             Campaign().set('turnorder',JSON.stringify(_.chain(                     filterObjs(                         selectedIDs.length ?                             (o)=>_.contains(selectedIDs,o.id) :                             (o)=>o.get('type')==='graphic' && o.get('pageid')===pageid && _.contains(['objects','gmlayer'],o.get('layer')) && o.get('represents') !== ''                     )                 )                 .map(                     (t)=>({ tokenid: t.id, characterid: t.get('represents'), initAttr: parseFloat(getAttrByName(t.get('represents'),initAttr,'current'))})                 )                 .reject((o)=>_.isUndefined(o.initAttr) || _.isNull(o.initAttr) || _.isNaN(o.initAttr) || !o.initAttr)                 .sort((o)=>(sortDirection*o.initAttr))                 .map((o)=>({id: o.tokenid, pr: o.initAttr.toFixed(2), custom:''}))                 .value()             ));         }     }); }); Cheers! =D
1479248290

Edited 1479252339
Mike W.
Pro
Sheet Author
Yes highest to lowest but your script is doing it lowest to highest so I made the change you made. Worked just fine with no bells and whistles, re-roll and clear for example (which is OK to me). Thank you so very much! Strange thing is that one token appears 3 times in the turn order, once with its actual graphic image and 2 times with the broken graphic image. All 3 have the correct initiative. Wonder what that is from? There no other other tokens on the VTT and when I select one of the broken ones in the Turn Order nothing is outlined on the VTT.. Any ideas? Mike