User:Misza13/Random
This template is an attempt at creating a "random number generator" using WikiSyntax. It generates pseudorandom numbers that change whenever a page containing it is edited or every minute (the latter update may require purging the page's cache).
Usage:
{{ {{NAMESPACE}}:{{PAGENAME}}}} produces a random decimal digit: {{{{NAMESPACE}}:{{PAGENAME}}}}{{ {{NAMESPACE}}:{{PAGENAME}}|N|M}} produces a random number from M to M+N-1, i.e. it rolls a 1dN+M-1, where the M, if ommited, is set to 0. (As you might've guessed by now, N defaults to 10.) Example:{{ {{NAMESPACE}}:{{PAGENAME}}|90|10}} generates a two-digit number: {{{{NAMESPACE}}:{{PAGENAME}}|90|10}}
You can (or rather should!) also specify up to 6 seeds for the generator, which (I think) should be different prime numbers:
{{ {{NAMESPACE}}:{{PAGENAME}}|seed1=7|seed2=47}} gives {{{{NAMESPACE}}:{{PAGENAME}}|seed1=47|seed2=7}}{{ {{NAMESPACE}}:{{PAGENAME}}|seed2=11|seed5=59|seed6=3}} gives {{{{NAMESPACE}}:{{PAGENAME}}|seed2=11|seed5=59|seed6=3}}
Notes:
- This template does not render properly when previewing a page. This is because the
{{REVISIONID}} variable (one of the sources of "randomness") is not set on preview. It will show up after saving, though. - The seed parameters should not be set to high values to avoid integer overflow. You'll know something's wrong when the generator produces negative numbers while it shouldn't.
({{REVISIONID}} +
{{User:Misza13/CURRENTMINUTEOFDAY}}*{{{seed1|131}}} +
{{CURRENTDAY}}*{{{seed2|53}}} +
{{CURRENTDOW}}*{{{seed3|37}}} +
{{CURRENTWEEK}}*{{{seed4|23}}} +
{{CURRENTMONTH}}*{{{seed5|13}}} +
{{CURRENTYEAR}}*{{{seed6|7}}} ) mod {{{1|10}}} + {{{2|0}}}
}}