Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Difference between revisions of "Script:Fetch"

From Roll20 Wiki

Jump to: navigation, search
m (transclude from Tim)
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
<noinclude>{{revdate}} {{main|Meta-Toolbox}}</noinclude>
+
<noinclude>{{revdate}} {{main|Meta-Toolbox}}{{Meta-ToolboxNav}}
'''{{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]].
+
=Fetch=</noinclude>
 +
'''{{fpl|10005732/ Fetch}}''' 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 Section|repeating attribute]].
 
* {{fpl|10422196/ (Meta Script) Fetch (Thread 2)}}
 
* {{fpl|10422196/ (Meta Script) Fetch (Thread 2)}}
 +
* {{forum|post/11103677/meta-script-fetch-v2-dot-0-now-with-status-player-page-marker-and-campaign-support Fetch 2.0 Documentation (most up to date)}}
 
<pre style="overflow:auto;white-space:pre-wrap;">Token property : @(selected.currentside)
 
<pre style="overflow:auto;white-space:pre-wrap;">Token property : @(selected.currentside)
 
Sheet Attribute: @(selected.Strength)
 
Sheet Attribute: @(selected.Strength)
Line 17: Line 19:
 
<pre style="overflow:auto;white-space:pre-wrap;">@(The President of Burundi.Coffee[default value here])</pre>
 
<pre style="overflow:auto;white-space:pre-wrap;">@(The President of Burundi.Coffee[default value here])</pre>
  
'''Syntax:'''
+
<noinclude>__TOC__</noinclude>
 +
<noinclude>==</noinclude>'''Syntax'''<noinclude>==</noinclude>
 
<pre style="overflow:auto;white-space:pre-wrap;">
 
<pre style="overflow:auto;white-space:pre-wrap;">
 
@(selected.token_id)                                              => token id of selected
 
@(selected.token_id)                                              => token id of selected
Line 26: Line 29:
 
@(Bob.Strength[0])                                                => default value if Strength doesn't exist
 
@(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.Strength.max[0])                                            => default value if max value of Strength doesn't exist
 +
 +
@(selected.imgsrc_short)                                          => The token's source image, leaving off everything after the '?', returning just the workable image URL.
 +
@(selected.tooltip)                                              => Returns the token's tooltip text.
 +
@(selected.show_tooltip)                                          => Returns the toggle status for whether the tooltip should be shown. NOTE: currently the status of this property is not accurately reported to the API when a change is made in the UI. This is a bug that Roll20 will have to address.
 +
 
*(Bob.spells.[name="Glitter Storm" prepared].spelllevel)          => repeating attribute from spells list where the name sub-attribute
 
*(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
 
                                                                     is "Glitter Storm" and the spell is prepared, returns the
Line 36: Line 44:
 
*(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$)            => 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>
 
*(Bob.spells.[name~Glitter prepared].spelllevel.name[not found])  => including a default value</pre>
 +
 +
See '''{{fpl|10005732/ Fetch}}''' for full documentation.
 +
 +
<noinclude>==</noinclude>'''Example'''<noinclude>==</noinclude>
 +
 +
Calling token_id by name of token in a [[TokenMod]] command. (normally you can't reference {{c|token_id}} by name, it only works for {{c|character_id}}):
 +
<pre>!token-mod --ids @(Charlie.token_id) --current-page --move =90|1g</pre>
 +
 +
General Calls
 +
<pre>
 +
@(Glitterbomb Gleek.InitiativeMod)        fetches normal attribute
 +
*(Bob the Slayer.spells.[name = "Disintegrating Blast" prepared].spell_level)    fetches the spell_level of a prepared “Disintegrating Blast”-spell from a repeating section
 +
@(Bob.UnderwaterMacrame[0])              fetches attribute, returns zero as default value if teh attribute doesn't exist
 +
</pre>
 
<noinclude>
 
<noinclude>
 
==Meta-Toolbox Examples==
 
==Meta-Toolbox Examples==
 
{{:Meta-Toolbox/Examples}}
 
{{:Meta-Toolbox/Examples}}
==Other APIs==
+
=Other APIs=
 
* [[ChatSetAttr]]
 
* [[ChatSetAttr]]
 
* [[ScriptCards]]
 
* [[ScriptCards]]

Latest revision as of 12:43, 19 September 2023

Main Page: Meta-Toolbox

Fetch

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])

Contents

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

@(selected.imgsrc_short)                                          => The token's source image, leaving off everything after the '?', returning just the workable image URL.
@(selected.tooltip)                                               => Returns the token's tooltip text.
@(selected.show_tooltip)                                          => Returns the toggle status for whether the tooltip should be shown. NOTE: currently the status of this property is not accurately reported to the API when a change is made in the UI. This is a bug that Roll20 will have to address.

*(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

See Fetch(Forum) for full documentation.

Example

Calling token_id by name of token in a TokenMod command. (normally you can't reference token_id by name, it only works for character_id):

!token-mod --ids @(Charlie.token_id) --current-page --move =90|1g

General Calls

@(Glitterbomb Gleek.InitiativeMod)         fetches normal attribute
*(Bob the Slayer.spells.[name = "Disintegrating Blast" prepared].spell_level)    fetches the spell_level of a prepared “Disintegrating Blast”-spell from a repeating section
@(Bob.UnderwaterMacrame[0])              fetches attribute, returns zero as default value if teh attribute doesn't exist

[edit] Meta-Toolbox Examples

Examples using one or more Meta-Toolbox APIs

[edit] Other APIs