Last active
August 29, 2015 14:00
-
-
Save Heilemann/11357802 to your computer and use it in GitHub Desktop.
Roll20 Highlight Current Turnorder Token
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); | |
if (current_token) { | |
var radius = current_token.get('aura2_radius'); | |
toFront(current_token); | |
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); | |
if (last_token) { | |
last_token.set({ | |
'aura2_radius': 0 | |
}); | |
} | |
} | |
state.jrl_initiative_last_token = turn.id; | |
}, 1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This isn't my original code, but I fixed it so it doesn't crash when a token isn't available for the current turn order item.