( EDIT: fixed the update as it didn't work, but it does now! ) Funny.. I just wrote a snippet of code that does this... here it is (I bolded the turn order bits for you): on('chat:message',function(msg) {
if (msg.type !== "api"){
return;
}
var tokenized = msg.content.split(" "),
command = tokenized[0];
switch(command) {
case '!init2':
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;
}
});