resetTablePicks: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 38: Line 38:
{{!}}}
{{!}}}
If this table is set to ''Pick Once'', then the Ace and Two of Clubs can be reset with any of:
If this table is set to ''Pick Once'', then the Ace and Two of Clubs can be reset with any of:
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h:resetTablePicks("Standard", "0,1")]
[h:resetTablePicks("Standard", "0,1")]
[h:resetTablePicks("Standard", "0@1", "@")]
[h:resetTablePicks("Standard", "0@1", "@")]
[h:resetTablePicks("Standard", json.append("", 0, 1), "json")]
[h:resetTablePicks("Standard", json.append("", 0, 1), "json")]
</source>
</syntaxhighlight>
'''Note''' that entries on ''Pick Once'' tables are identified by list index (starting at 0), and ''not'' by range as in normal tables.  Take care to properly identify entries when resetting.  For more info, see [[Introduction to Tables#Pick Once Tables|Introduction to Tables]] and the {{func|table}} function.
'''Note''' that entries on ''Pick Once'' tables are identified by list index (starting at 0), and ''not'' by range as in normal tables.  Take care to properly identify entries when resetting.  For more info, see [[Introduction to Tables#Pick Once Tables|Introduction to Tables]] and the {{func|table}} function.
|also=
|also=

Latest revision as of 22:32, 14 March 2023

resetTablePicks() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.6.0
Resets the entries in a table that have been picked. The individual entries in a Pick Once table can only be randomly chosen once until the table is reset with this function. This can be used to simulate a deck of cards where a card picked is no longer available for future picks until the deck is re-shuffled. Note: When specifying specific entries to be reset, it is important to note that Pick Once tables behave a bit differently than regular tables. In particular, entries are identified and selected by list index (starting at 0), and do not take configured ranges into account. See examples for details.

Usage

resetTablePicks(tableName)
resetTablePicks(tableName, entriesToReset)
resetTablePicks(tableName, entriesToReset, delim)
resetTablePicks(tableName, entriesToReset, "json")

Parameters

  • tableName - A string containing the name of the Table.
  • entriesToReset - Since 1.8. Identifies specific entries to be reset. Can be a String List using the provided delim (defaults to "," if no delim provided), or a JSON Array if delim is "json".
  • delim - Since 1.8. Custom delimiter for the `entriesToReset` param. Defaults to ",". Should be "json" if entriesToReset is a JSON Array instead of a String List.

Examples

[r:resetTablePicks("Poker Deck")]

Result: Table is reset so that all entries are available to be chosen again.

Resetting specific entries (Since 1.8)

Consider this excerpt from the beginning of the "Standard" Default Table (containing 52 playing card images):

Default Table "Standard"
1 Ace of Clubs
2 Two of Clubs
3 Three of Clubs
...

If this table is set to Pick Once, then the Ace and Two of Clubs can be reset with any of:

[h:resetTablePicks("Standard", "0,1")]
[h:resetTablePicks("Standard", "0@1", "@")]
[h:resetTablePicks("Standard", json.append("", 0, 1), "json")]
Note that entries on Pick Once tables are identified by list index (starting at 0), and not by range as in normal tables. Take care to properly identify entries when resetting. For more info, see Introduction to Tables and the table() function.

See Also

Version Changes

  • 1.8 - Added optional params to reset only specific entries