
Fetch (Updated Thread)
FILE LOCATION: My Personal Repo and 1-click (as of 22 Nov 2022 merge)
META SCRIPT: This script is a meta-script, and part of the ZeroFrame Meta Toolbox. It can be used on its own, or in conjunction with ZeroFrame and the other meta-toolbox scripts, to modify other scripts' API commands.
ABSTRACT: Fetch provides a standardized way to retrieve game data with a syntax very close to Roll20 Galactic Standard. This can be game data not previously exposed to the chat interface (like the current side of a multi-sided token), or even data that has been available, but now with the ability to arrive at it in different ways (like getting character properties from the speaker, or token properties from the tracker, or character abilities from the selected token). In addition, Fetch improves on the standard Roll20 sheet retrieval syntax by allowing you to specify a default value if the item does not exist (instead of erroring to chat). Original forum post is here.
SUPPORTING SCRIPTS: Fetch requires The Aaron's libTokenMarkers script as well as timmaugh's Messenger script, all of which are available in the 1-click installer.
When, Where, and Why Fetch
Fetch seeks to mimic what Roll20 offers in terms of retrieval syntax, and also to expand upon it. As a metascript, it doesn't preempt your command line from reaching the intended target (another Mod Script), it simply detects things to do along the way. It modifies the command line by fetching the data you ask for from the game, then lets the message travel on to be picked up by the intended destination script. In other words, it functions quite similarly to the way you would use standard Roll20 formations, except that it has several key benefits, and reasons/times to use it over Roll20 standard syntax:
- Fetch offers a default value: instead of breaking the chat input if you request something that doesn't exist, Fetch will substitute in a default value. If you do not provide a default value, the default-default is an empty string. See Default Values for more info.
- Fetch can retrieve more things than Roll20 standard: Fetch can retrieve many more properties from many more things within a game. For instance, it can retrieve the top or left properties from a token, unavailable using standard Roll20 syntax. It can retrieve status values, page names, player properties, and much more.
- Fetch resolves after Roll20 query parsing and ability expansion: This one can get technical, but... remembering that Roll20 queries can break if certain HTML substitutions are not followed, Fetch offers a way to skip any substitutions. Since Fetch doesn't resolve until after Roll20 parsing, it doesn't expand its syntax into the retrieved information until after the queries have been parsed.
- Fetch works with other metascripts: Because Fetch is part of the metascript toolbox, it plays well with the other metascripts, allowing you to do things like iterate over selected tokens and retrieve individual data for each.
What You Could Always Get (v1.x.x)
In previous versions, you could get token properties, character properties, character attributes, character repeating attributes, character abilities, and macros. You could also use tracker references to get information about a token from the Turn Tracker, including using a positive or negative offset to get information from other tokens in the turn structure. If you were speaking as a character, you could also use speaker constructions to return character information (properties, attributes, repeating attributes, or abilities).
What New Things You Can Get (v2.0.0)
As of v2.0.0, you can get all of the above structures with the same syntax as you ever could, but you can also get player properties, page properties, campaign properties, marker properties, and token status properties (is the status assigned to this token? what is the value? what is the string of all the values together? what is the total of the values for all of the markers of a given type?) -- and return that information to your command line to use. That means you could stash any sort of data in token markers and retrieve it as parameters to other scripts, or to inline rolls (with ZeroFrame installed, too).
The list of pseudo properties has also been expanded.
Pseudo-Property: A pseudo-property is a property that isn't attached to the object by default, but which has only one potential value, so it can be assigned to a retrievable handle. For instance, if a token represents a character, it stores the ID of that character in the represents property. Since there is only 1 potential value for that character's name (and many times that might be more helpful to know), Fetch also offers a represents_name property (a pseudo-property).
Fetch 2.0.0 expands the set of pseudo-properties, especially around the idea of status markers. See the sections Pseudo-Properties and/or Token Status Properties for more information.
Finally, if you have the checkLightLevel installed, Fetch will incorporate that script to provide two additional pseudo-properties (one representing if the token is in bright light, and one reporting the total light hitting the token). (...continued-->)