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

[Request] TokenLock

So looks like all the Tokenlock threads are closed so I thought i'd put this out there, because I know Aaron's to do list is so SHORT. :) Script works great does exactly what its suppose to do. However I've ran into a couple snags that may be able to be fixed together. This script doesn't like the BUMP Script, i get this error when attempting to move a "Bumped" NPC while the Token's are locked. The other request is to allow the DM to move the token without restriction, even though the player has to wait for their turn order, i'm thinking that perhaps by allowing the GM the ability to do this, it might make the BUMP script happy too? Thoughts?
Was the turn tracker empty when you came across that problem? Because it looks like TokenLock should fail like that for an empty turn tracker regardless of any other scripts. There's an unfortunate subtle point in javascript with respect to truthiness: an empty array compares equal to false, but when evaluated for truthiness implicitly it comes back truthy, so a construct like ([]||[foo])[0] will yield undefined instead of foo. This comes up on line 204 of the latest version of TokenLock in the repo (I'm not sure what version you're on; the capitalization of "HandleMove" suggests it's older than the latest version, so your line number is probably different): (JSON.parse(Campaign().get('turnorder'))||[{id:false}])[0] can yield undefined if the turn tracker is empty. It could be fixed like: ((JSON.parse(Campaign().get('turnorder'))||[])[0]||{id:false})
It's bizarre. I'd say you may need to ensure both are updated (like manveti pointed out) because I can have tokens locked, and still move bumped tokens when it's not their turn.
manveti said: Was the turn tracker empty when you came across that problem? Because it looks like TokenLock should fail like that for an empty turn tracker regardless of any other scripts. There's an unfortunate subtle point in javascript with respect to truthiness: an empty array compares equal to false, but when evaluated for truthiness implicitly it comes back truthy, so a construct like ([]||[foo])[0] will yield undefined instead of foo. This comes up on line 204 of the latest version of TokenLock in the repo (I'm not sure what version you're on; the capitalization of "HandleMove" suggests it's older than the latest version, so your line number is probably different): (JSON.parse(Campaign().get('turnorder'))||[{id:false}])[0] can yield undefined if the turn tracker is empty. It could be fixed like: ((JSON.parse(Campaign().get('turnorder'))||[])[0]||{id:false}) Yep thats what it was, version was outdated. Had to look at the script wiki to find the latest version. Thanks for the help and direction guys.
1429846155
The Aaron
Pro
API Scripter
Yeah, Manveti is right about that. Well explained too! That's an old script to be sure! Speaking to the moving by the GM: unfortunately the on('change:graphic',...) event doesn't tell you who did the change. In the case of a graphic with no owner or just the GM as owner, token lock can safely allow the move. If there is a player on it, it has to prevent it.
The Aaron said: Yeah, Manveti is right about that. Well explained too! That's an old script to be sure! Speaking to the moving by the GM: unfortunately the on('change:graphic',...) event doesn't tell you who did the change. In the case of a graphic with no owner or just the GM as owner, token lock can safely allow the move. If there is a player on it, it has to prevent it. Ah makes sense, thanks Aaron.