resetTablePicks: Difference between revisions
Jump to navigation
Jump to search
(Added optional params coming in 1.8, resetting only specific entries.) |
m (Updating to reflect that 1.8 has been released.) |
||
Line 8: | Line 8: | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
resetTablePicks(tableName) | resetTablePicks(tableName) | ||
resetTablePicks(tableName, entriesToReset) | resetTablePicks(tableName, entriesToReset) | ||
resetTablePicks(tableName, entriesToReset, delim) | resetTablePicks(tableName, entriesToReset, delim) | ||
Line 17: | Line 14: | ||
'''Parameters''' | '''Parameters''' | ||
{{param|tableName|A string containing the name of the Table.}} | {{param|tableName|A string containing the name of the Table.}} | ||
{{param|entriesToReset|'' | {{param|entriesToReset|''Since 1.8''. Identifies specific entries to be reset. Can be a [[String List]] using the provided delim (defaults to {{code|","}} if no delim provided), or a [[JSON Array]] if delim is {{code|"json"}}.}} | ||
{{param|delim|'' | {{param|delim|''Since 1.8''. Custom delimiter for the `entriesToReset` param. Defaults to {{code|","}}. Should be {{code|"json"}} if entriesToReset is a [[JSON Array]] instead of a [[String List]].}} | ||
|examples= | |examples= | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
Line 24: | Line 21: | ||
</source> | </source> | ||
'''Result:''' Table is reset so that all entries are available to be chosen again. | '''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): | Consider this excerpt from the beginning of the "Standard" Default Table (containing 52 playing card images): | ||
{{{!}} class="wikitable" | {{{!}} class="wikitable" |
Revision as of 05:59, 16 February 2021
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")]
See Also
Version Changes
- 1.8 - Added optional params to reset only specific entries