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

How to retrieve current vision and light of a token?

Hi I'm trying to use a chat menu to set up vision and light of a token. the idea is to show the current token status regarding these and then provide button that invoke tokenmod to adjust the parameters the tokenmod part works fine but I cannot find how to retrieve the current status. either I cannot find the proper name or it is not straightforward to get for bright light vision for example I tried the straightforward @{selected|has_bright_light_vision} that does not work (while @{selected|bar1} works fine so it is not the command structure). looking around I found fetch that seems to say that there are indeed such parameters that cannot be called but it does not seem I can load fetch in the game and use it as is... any suggestion on how to fix or on a script that already does what I am trying to build? thanks Andrea
1695045980
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Have you looked at Dynamic Lighting Tool ? This is exactly what it was built to do. Plus, it includes a diagnostic report to solve most common lighting and vision issues.
keithcurtis said: Have you looked at Dynamic Lighting Tool ? This is exactly what it was built to do. Plus, it includes a diagnostic report to solve most common lighting and vision issues. just WOW!!! many thanks is what I wanted to do and so much more!!!! Andrea
Andrea L. said: the idea is to show the current token status regarding these and then provide button that invoke tokenmod to adjust the parameters the tokenmod part works fine but I cannot find how to retrieve the current status. either I cannot find the proper name or it is not straightforward to get for bright light vision for example I tried the straightforward @{selected|has_bright_light_vision} that does not work (while @{selected|bar1} works fine so it is not the command structure). Just an FYI to this point: there are a few token attributes that are exposed to chat reference calls (such as bar1, token_name, etc.) but most other features are not exposed to chat. However, Mod scripts do have exposure to those elements, but how they are referenced and shown to a player depends on how the script was written. So there's no basic chat command that will retrieve Dynamic Lighting status from a token; what attribute a bar is linked to; size, shape and color of an aura; or what style of bar (standard or compact) a token has, as examples. Any of those can only be referenced through a script.
1695065213
timmaugh
Pro
API Scripter
I agree that DLTool is the script you're looking for, but, as the author of Fetch, I should clarify. Fetch uses parentheses as the outer boundaries of the text formations, so something like this: @(selected|has_bright_light_vision) It doesn't have to be a pipe character separating the property from the character identifier (the "selected")... it could instead a use a period. That's the way I use it, typically, so that it's another visual indication: @(selected.has_bright_light_vision) Now, how do you see the value? Metascripts are specifically aimed at changing the message object -- altering the command line or adding data that scripts can later use. The point is that your ability to see the result of a Fetch construction (for instance, retrieving the "has_bright_light_vision" setting of a token) amounts to changing the command line. This: @(selected.has_bright_light_vision) ...becomes: true (or false) Now, while a mod script can take action on a message that is simply intended for the chat output (that is, it doesn't begin with an exclamation point so it just gets output to the chat), we can't interrupt the output that hits the chat panel. That is, we can't use a script to change what is in the message *before* the user sees the original message. We could, at best, output a second message after the first that would contain our changes. That's not very helpful. So, in order to use metascripts, the requirement is that you begin your command as if it were intended for a script -- start it with an exclamation point -- even if you don't intend to invoke a script like TokenMod, Spawn, ScriptCards, etc. Even if you just want to output text to the chat, but you want that text to include information retrieved/constructed by the metascripts, start it with an exclamation point. That keeps something from hitting the chat initially and gives the metascripts time to do their thing. Now we have a message that we're able to change, but it won't hit the chat. So how do you actually see it? That's where ZeroFrame (the organizing metascript) comes in. Specifically, using the {&simple} tag. That tag tells the metascripts that, whenever their work is done, they should output the now-altered message to chat. All of that together means that you could do something like: !The value is @(selected.has_bright_light_vision){&simple} ...or... !&{template:default}{{name=Proof of Concept}}{{Bright Vision=@(selected.has_bright_light_vision)}}{&simple} ...if you wanted the look of a template.
many thanks.. very clear....I'll use the DLtool as it does exactly what I needed in a much nicer way but I really appreciate the explanation ...for future use Andrea