Difference between revisions of "Script:Fetch"
From Roll20 Wiki
Andreas J. (Talk | contribs) m |
Andreas J. (Talk | contribs) m (transclude from Tim) |
||
Line 1: | Line 1: | ||
− | + | <noinclude>{{revdate}} {{main|Meta-Toolbox}}</noinclude> | |
+ | '''{{fpl|10005732/ Fetch}}''' offers a unified syntax to expand the amount of things that can be retrieved with simple [[token]] or [[macros|sheet calls]]. You can retrieve any token property, sheet attribute, or [[Repeating Section|repeating attribute]]. | ||
+ | * {{fpl|10422196/ (Meta Script) Fetch (Thread 2)}} | ||
+ | <pre style="overflow:auto;white-space:pre-wrap;">Token property : @(selected.currentside) | ||
+ | Sheet Attribute: @(selected.Strength) | ||
+ | Sheet Attribute: @(Bob the Hirsute.Strength.max) | ||
+ | Repeating Attr : *(Englebert Slaptiback.spells.[spell_name~Fireball prepared].spell_roll)</pre> | ||
+ | |||
+ | It also expands the source of the returned sheet item to include "speaker". | ||
+ | |||
+ | <pre style="overflow:auto;white-space:pre-wrap;">@(speaker.Strength.max)</pre> | ||
+ | |||
+ | ... and can return the rowID of a repeating attribute, the row number ($0), or the name of either brand of reference. | ||
+ | |||
+ | Not only do these offer the advantage of not breaking the chat message if they don't exist (the way a standard token or sheet item call would), they also give you the ability to substitute in a default value should the one you are looking for not exist: | ||
+ | |||
+ | <pre style="overflow:auto;white-space:pre-wrap;">@(The President of Burundi.Coffee[default value here])</pre> | ||
+ | |||
+ | '''Syntax:''' | ||
+ | <pre style="overflow:auto;white-space:pre-wrap;"> | ||
+ | @(selected.token_id) => token id of selected | ||
+ | @(Bob.Strength) => attribute of character | ||
+ | @(speaker.Strength) => attribute of current speaking character | ||
+ | @(Bob.Strength.max) => max value | ||
+ | @(Bob|Strength|max) => pipes or periods work | ||
+ | @(Bob.Strength[0]) => default value if Strength doesn't exist | ||
+ | @(Bob.Strength.max[0]) => default value if max value of Strength doesn't exist | ||
+ | *(Bob.spells.[name="Glitter Storm" prepared].spelllevel) => repeating attribute from spells list where the name sub-attribute | ||
+ | is "Glitter Storm" and the spell is prepared, returns the | ||
+ | spelllevel sub-attribute | ||
+ | *(Bob.spells.[name~Glitter prepared].spelllevel.name) => where the name sub-attribute includes the text "Glitter", | ||
+ | return the full name of the spelllevel sub-attribute | ||
+ | *(Bob.spells.[name~Storm name!~Glitter].spelllevel.rowid) => where the name sub-attribute includes "Storm" but not "Glitter", | ||
+ | whether or not the spell is prepared; return the rowid | ||
+ | *(Bob.spells.[name~Glitter prepared].spelllevel.row$) => where name includes "Glitter" and is prepared, return the row number (i.e., $1) | ||
+ | *(Bob.spells.[name~Glitter prepared].spelllevel.name$) => where name includes "Glitter" and is prepared, return the name using the row number | ||
+ | *(Bob.spells.[name~Glitter prepared].spelllevel.name[not found]) => including a default value</pre> | ||
+ | <noinclude> | ||
+ | ==Meta-Toolbox Examples== | ||
+ | {{:Meta-Toolbox/Examples}} | ||
+ | ==Other APIs== | ||
+ | * [[ChatSetAttr]] | ||
+ | * [[ScriptCards]] | ||
+ | * [[TokenMod]] | ||
[[Category:API Meta Scripts]] | [[Category:API Meta Scripts]] | ||
[[Category:User API Scripts]] | [[Category:User API Scripts]] | ||
− | [[Category:Macros]] | + | [[Category:Macros]]</noinclude> |
Revision as of 08:10, 14 February 2022
Page Updated: 2022-02-14 |
Fetch(Forum) offers a unified syntax to expand the amount of things that can be retrieved with simple token or sheet calls. You can retrieve any token property, sheet attribute, or repeating attribute.
Token property : @(selected.currentside) Sheet Attribute: @(selected.Strength) Sheet Attribute: @(Bob the Hirsute.Strength.max) Repeating Attr : *(Englebert Slaptiback.spells.[spell_name~Fireball prepared].spell_roll)
It also expands the source of the returned sheet item to include "speaker".
@(speaker.Strength.max)
... and can return the rowID of a repeating attribute, the row number ($0), or the name of either brand of reference.
Not only do these offer the advantage of not breaking the chat message if they don't exist (the way a standard token or sheet item call would), they also give you the ability to substitute in a default value should the one you are looking for not exist:
@(The President of Burundi.Coffee[default value here])
Syntax:
@(selected.token_id) => token id of selected @(Bob.Strength) => attribute of character @(speaker.Strength) => attribute of current speaking character @(Bob.Strength.max) => max value @(Bob|Strength|max) => pipes or periods work @(Bob.Strength[0]) => default value if Strength doesn't exist @(Bob.Strength.max[0]) => default value if max value of Strength doesn't exist *(Bob.spells.[name="Glitter Storm" prepared].spelllevel) => repeating attribute from spells list where the name sub-attribute is "Glitter Storm" and the spell is prepared, returns the spelllevel sub-attribute *(Bob.spells.[name~Glitter prepared].spelllevel.name) => where the name sub-attribute includes the text "Glitter", return the full name of the spelllevel sub-attribute *(Bob.spells.[name~Storm name!~Glitter].spelllevel.rowid) => where the name sub-attribute includes "Storm" but not "Glitter", whether or not the spell is prepared; return the rowid *(Bob.spells.[name~Glitter prepared].spelllevel.row$) => where name includes "Glitter" and is prepared, return the row number (i.e., $1) *(Bob.spells.[name~Glitter prepared].spelllevel.name$) => where name includes "Glitter" and is prepared, return the name using the row number *(Bob.spells.[name~Glitter prepared].spelllevel.name[not found]) => including a default value
Meta-Toolbox Examples
Examples using one or more Meta-Toolbox APIs
- Managing PathFinder Sizes with TokenMod and Metascripts (Muler + TokenMod, extra stuff w/ ZeroFrame, SelectManager, Fetch)
- Using TokenMod to update multiple token tooltips (TokenMod + SelectManager + Fetch + ZeroFrame)
- Macro to read current face of Rollable Token
- Repeating Sections & ChatSetAttr(Forum)
- First example: Plugger and SelectManager; Second example: Plugger, Muler, SelectManager, and ZeroFrame.
- Using MathOps standalone, more details(Forum)
- API Logic and Libinline(Forum)
- selectmanager example(Forum)
- ZeroFrame example with ColorEmote(Forum)
- Table example with Muler & ZeroFrame(Forum)
- Muler + more example(Forum)
- Dealer -- Is there a way to deal to a player, even if that player's token is not selected?(Forum) - Selectmanager example
- Audio Master API(Forum) - fixes with MathOps & Muler
- Fix "It's a Trap" with selectmanager(Forum)
- Search Attributes(Forum) - InsertArg example
- Is there an API that can roll saves for groups then apply a condition to the tokens that failed?(Forum) - selectmanager example
- TokenMod API - how to select token without clicking it(Forum) selectmanager fix TokenMod limitation
- default token size fix(Forum) Muler & Fetch examples
- Multi-step table resolution (Pacesetter system)(Forum) - Muler with ZeroFrame example
- Creating a HUD(Forum) - ZeroFrame, Fetch example working with TokenMod
- Retrieving next item in list(Forum) - Muler, ZeroFrame, and APILogic example
- Retrieving or assigning individual data to/from many tokens with deferred inline rolls(Forum) - examples of SelectManager's forselected handle using various metascripts with TokenMod