table: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
Gets the text value from the specified {{code|table}}. If the row is not specified then the default {{code|roll}} for the {{code|table}} is used. The row can be either a constant or a {{code|roll}}.
Gets the text value from the specified {{code|table}}. If the row is not specified then the default {{code|roll}} for the {{code|table}} is used. The row can be either a constant or a {{code|roll}}.


Note that what this function returns is interpreted as either a string or a number. You can put code in a table entry but that too will be returned as a string and will not be evaluated. To evaluate the result you can use {{func|eval}} to evaluate e.g. the table entry 1d5 and {{func|evalMacro}} to evaluate e.g. the table entry [r:1d5]
Note that what this function returns is interpreted as either a string or a number. You can put code in a table entry but that too will be returned as a string and will not be evaluated. To evaluate the result you can use {{func|eval}} to evaluate e.g. the table entry {{code|1d5}} and {{func|evalMacro}} to evaluate e.g. the table entry [r:1d5]


|usage=
|usage=

Revision as of 10:04, 31 January 2014

table() Function

Introduced in version 1.3b39
Gets the text value from the specified table. If the row is not specified then the default roll for the table is used. The row can be either a constant or a roll. Note that what this function returns is interpreted as either a string or a number. You can put code in a table entry but that too will be returned as a string and will not be evaluated. To evaluate the result you can use eval() to evaluate e.g. the table entry 1d5 and evalMacro() to evaluate e.g. the table entry [r:1d5]

Usage

table(name)
table(name, row)
tbl(name)
tbl(name, row)

Parameters

  • name - A string containing the name of the table.
  • row - The row of the table that should be returned.

Examples

Example 1: Display a random value from table "tbl1" using default roll:
[r: table("tbl1")]

Example 2: Display the first value from table "tbl1":

[r: table("tbl1", 1)]

Example 3: Display one of the first four values from "tbl1", chosen randomly:

[r: table("tbl1", "1d4")]

Example 4: Display a table row that corresponds to a token property's value (the value must be numeric):

[r: table("tbl1", Intelligence)]
[r: table("tbl1", getProperty("PCLevel"))]

See Also

Tables, tableImage() There is a tool available to import tables from excel. You can find more about this here