It is nice to have a button in empty story river or on the sidebar, on lick shows a random tiddler. I have such a button in TW-Scripts and Mehregan. The button uses the computer time as seed and its output is deterministic, so it does not generate a real random number, but is very handy for our daily use and has no performance impact.
This solution is pure WikiText, no JavaScript.
\define randomTiddler(filter, label)
<$let seed=<<now XXX>>
minNum = 1
maxNum = {{{ [subfilter<__filter__>count[]] }}}
randNum = {{{ [<maxNum>subtract<minNum>multiply<seed>divide[999]add<minNum>round[]] }}}
>
<$link to={{{ [subfilter<__filter__>nth<randNum>] :else[subfilter<__filter__>first[]] }}}>$label$</$link>
</$let>
\end
Logic
If we linearly map [0, 999] into [alpha:1, beta:n] where alpha is the first tiddler and beta is the number of tiddlers to be used for random display! from mathematics we have
x in [0, 999] (this will be generated by now macro)
y in [alpha, beta] (this is the numbers we like)
then y= (beta - alpha) / 999 * x + alpha
To give a try
- download Random Tiddler Macro.json (743 Bytes)
- drag and drop on https://tiddlywiki.com/
- open Test and click on
Random Tiddler
References
- https://groups.google.com/g/tiddlywiki/c/GuQ0EMKfZaM/m/WCo26CxqAwAJ
- Using Randomness in TiddlyWiki - Discussion - Talk TW
- Scripts in Tiddlywiki — codes, macros, and solutions in TW (credits go to @twMat)
Please add your alternative solution to this thread.
Could you (or another Tiddlywiki guru) advise on how to make it randomly pick a link within a SUBSET of all tiddlers in a wiki, as defined by a title or body pattern-match? – for example, a random tiddler with a name beginning “Unicorn” or containing the word “Documentation”?
only beginning the first baby-steps of my journey into the Tiddlywiki world, and am in awe of the power the system offers and the friendliness of the TW community!
… many thanks for any & all advice on how to learn to do this sort of thing … after 20+ years my
)