getTableEntry: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{MacroFunction |name=getTableEntry |proposed=false |deprecated= |trusted=true |version=1.5.4 |description= Retrieves the raw table data for the specified entry as a JSON obje...") |
Full Bleed (talk | contribs) m (Added "picked" return element in the example.) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 6: | Line 6: | ||
|version=1.5.4 | |version=1.5.4 | ||
|description= | |description= | ||
Retrieves the raw table data for the specified entry as a JSON object. Returns an empty string if the entry doesn't exist. If no image is associated with the entry the {{code | Retrieves the raw table data for the specified entry as a JSON object. Returns an empty string if the entry doesn't exist. If no image is associated with the entry the {{code|assetid}} will be an empty string. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro"> | ||
getTableEntry(table, roll) | getTableEntry(table, roll) | ||
</ | </syntaxhighlight> | ||
'''Parameters''' | '''Parameters''' | ||
{{param|table|Name of table as a string.}} | {{param|table|Name of table as a string.}} | ||
Line 18: | Line 18: | ||
|example= | |example= | ||
Get the entry from table "Critters" matching a roll of 4. | Get the entry from table "Critters" matching a roll of 4. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: getTableEntry("Critters", 4)] | [r: getTableEntry("Critters", 4)] | ||
</ | </syntaxhighlight> | ||
Returns: | Returns: | ||
< | <syntaxhighlight lang="javascript"> | ||
{"min":3, "max":5, "value": "duck", "assetid":""} | {"min":3, "max":5, "value": "duck", "picked":false, "assetid":""} | ||
</ | </syntaxhighlight> | ||
|also= | |also= |
Latest revision as of 04:04, 25 October 2024
getTableEntry() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.5.4
Retrieves the raw table data for the specified entry as a JSON object. Returns an empty string if the entry doesn't exist. If no image is associated with the entry the
assetid
will be an empty string.Usage
getTableEntry(table, roll)
Parameters
table
- Name of table as a string.roll
- The entry to retrieve as if a roll of that value had been made.
Example
Get the entry from table "Critters" matching a roll of 4.
[r: getTableEntry("Critters", 4)]
Returns:
{"min":3, "max":5, "value": "duck", "picked":false, "assetid":""}