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

Tokens without character sheets

Was wanting a roll that was something like this: [[1d20+{0d0+(@{selected|bar1}/3), 0d0+@{selected|init}}kh1 ]] that would be able to pull a feild from a character @{selected|init} or a value from a token that doesn't have a sheet @{selected|bar1} and compare them and add the better of the two to a roll. This way I could use same macro for both NPC and PC. (most of my NPC are not using a character sheet they are just tokens) Is this possible?
I'd have to test but I'm fairly certain the macro would return an error of the 'data not found' variety if there's no sheet.
It does, but it also processes the math for the bar1 part then just gives me the d20 roll. I was wondering if there is a way to cause the @{selected|init} part to basically be zero if it doesn't exist? Or do I just need to bite the bullet and upgrade to Mentor :) Seems I want to do a lot of things the API is for.
Conditionals and data validation are firmly in the realm of the API, yeah.
1404744711

Edited 1404745492
The Aaron
Roll20 Production Team
API Scripter
There are plenty of nice things you can do with the API. =D Your example would certainly be possible with an API script. Assuming you want to add the rolls to the turn order, it would look something like this ( untested Now Tested and Corrected! ) snippet of code: on('chat:message',function(msg) { if (msg.type !== "api"){ return; } var tokenized = msg.content.split(" "), command = tokenized[0]; switch(command) { case '!init': if (msg.selected) { var turnorder=Campaign().get('turnorder'); if("" === turnorder) { turnorder = []; } else { turnorder = JSON.parse(turnorder); } _.each(msg.selected, function(o) { var obj = getObj(o._type,o._id), mod = 0, result = 0, init, found; if (obj && 'token' === obj.get('subtype')) { if ("" !== obj.get('represents')) { init = findObjs({ _type: 'attribute', _characterid: obj.get('represents'), name: 'init' })[0]; if ( init ) { mod = Math.round(+init.get('current'),0); } } else { mod=Math.round( (obj.get('bar1_value')/3), 0); } result = randomInteger(20)+mod; found = false; for(var i=0; i < turnorder.length; ++i) { if(obj.id === turnorder[i].id) { turnorder[i].pr=result; found=true; break; } } if(!found) { turnorder.push({id:obj.id,pr:result}); } } }); Campaign().set('turnorder',JSON.stringify(turnorder)); } break; } });
1404792066

Edited 1404793478
Can I just use a default character sheet for all monster tokens that has the attribute field set to init=0 making this macro always use the bar? I appreciate all the work, but that just seems a very convoluted way to skin a cat... If I have one character sheet (journal) and just have all NPC tokens represent that sheet w/o having a "default" token on that sheet will they all pull that value? ( Edit ): That worked like a champ. And allows me to store a few extra variables. I can actually use a character sheet to store all my variables that I am having a hard time carriying over from macro to macro. Might be able to delay upgrading to Mentor till payday after all. Granted I'll have to hard code the variables into tables or such but is promising.
1404793491
The Aaron
Roll20 Production Team
API Scripter
You certainly can have a default npc sheet with init:0, the version I wrote above looks for a character and attribute first, then falls back to the value of the bar. It's not so very convoluted, just flexible. :)
1404793607
The Aaron
Roll20 Production Team
API Scripter
Cool. Glad it's working for you! I just wanted to fully express your options with the script, and I got double duty out of it as someone asked right after you about scripting an initiative change. Score! :)
Don't get me wrong, I'm going to get access to the API it is amazing. And I can already see that the things I want to do, that I'm used to doing with my existing (but differently powerful) toolset will require it. And I wanted to learn another programing language anyway. :)
1404823323
The Aaron
Roll20 Production Team
API Scripter
I recommend JavaScript: the Good Parts by Douglas Crockford: JavaScript: The Good Parts by Douglas Crockford <a href="http://www.amazon.com/dp/0596517742/ref=cm_sw_r_udp_awd_7B-Utb0BV765A" rel="nofollow">http://www.amazon.com/dp/0596517742/ref=cm_sw_r_udp_awd_7B-Utb0BV765A</a>
Thanks for the book tip Aaron. I work at a small community bank and used to make my living as a programmer, then as I moved up the food chain and we went serviced the programming got left behind...and I miss it. I just ordered the book and I'm looking forward to trying my hand at Java.
1404827560
The Aaron
Roll20 Production Team
API Scripter
Hey Aladar. Full disclosure: JavaScript is not Java. Javascript is the language of the API though, so you'll get good milage out of it. =D