Last active
July 8, 2016 00:20
-
-
Save rlittlefield/5538171 to your computer and use it in GitHub Desktop.
Roll20 API - Highlight whichever token is currently up for initiative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on('ready', function() { | |
jrl_initiative_timer = setInterval(function() { | |
var c = Campaign(); | |
var pre_turnorder = c.get('turnorder'); | |
if (!pre_turnorder) { | |
return; | |
} | |
try { | |
var turn_order = JSON.parse(c.get('turnorder')); | |
} catch (e) { | |
log(e); | |
return; | |
} | |
if (!turn_order.length) { | |
return; | |
} | |
var turn = turn_order.shift(); | |
var current_token = getObj('graphic', turn.id); | |
var radius = current_token.get('aura2_radius'); | |
if (!radius) { | |
current_token.set({ | |
'aura2_radius': 1, | |
'aura2_color': '#0000DD', | |
'aura2_square': false | |
}); | |
} else { | |
current_token.set({ | |
'aura2_radius': 0 | |
}); | |
} | |
if (turn.id != state.jrl_initiative_last_token && state.jrl_initiative_last_token) { | |
var last_token = getObj('graphic', state.jrl_initiative_last_token); | |
last_token.set({ | |
'aura2_radius': 0 | |
}); | |
} | |
state.jrl_initiative_last_token = turn.id; | |
}, 1500); | |
}); |
I fixed the problems I had with it, and put it here: https://github.com/Heilemann/roll20-tor-scripts/blob/master/tor-highlight-token-on-turn.js, let me know if that's not okay.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems to break when it encounters a Custom Item in the turn order.