getTableEntry: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page GetTableEntry to getTableEntry: Converting page titles to lowercase)
m (Text replacement - "source>" to "syntaxhighlight>")
Line 11: Line 11:
<source lang="mtmacro">
<source lang="mtmacro">
getTableEntry(table, roll)
getTableEntry(table, roll)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|table|Name of table as a string.}}
{{param|table|Name of table as a string.}}
Line 20: Line 20:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: getTableEntry("Critters", 4)]
[r: getTableEntry("Critters", 4)]
</source>
</syntaxhighlight>
Returns:
Returns:
<source lang="javascript">
<source lang="javascript">
{"min":3, "max":5, "value": "duck", "assetid":""}
{"min":3, "max":5, "value": "duck", "assetid":""}
</source>
</syntaxhighlight>


|also=
|also=

Revision as of 19:10, 14 March 2023

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

<source lang="mtmacro"> getTableEntry(table, roll) </syntaxhighlight> 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.

<source lang="mtmacro" line> [r: getTableEntry("Critters", 4)] </syntaxhighlight> Returns: <source lang="javascript"> {"min":3, "max":5, "value": "duck", "assetid":""}

</syntaxhighlight>

See Also