Template:RandomChoice

From Nova Sector 13
Revision as of 18:16, 14 September 2024 by GreytideSkye (talk | contribs) (Clarification that angry red letters are intended on this page.)
Jump to navigation Jump to search

{{{ Division by zero. }}} (That should absolutely say "Division by zero." in angry red letters, as it has zero parameters given to it.)

Behold, great syntactic sin: First choice!

The math takes the "current" unix time, modulus the number of parameters given, and returns {{{ that number }}} which thusly returns that numbered parameter. One is added because parameters are one-indexed and modulus returns start at 0.

Of note, the unix time is taken when "the page was last rendered into HTML.", so if you have several random choices (with the same # of parameters) on a page, they all have the same time, so they'll all line up. We'd need a different extension to get an actual psuedo-random number, but at that point we're doing flat-out coding in our wiki and there's no way in hell that's gonna fly.

See:

Should be the same letter: c==C

might be different: c != d

for testing: 1/3, 3/5, 3/7.


Works for up to 10 parameters but could easily be extended to 20, 30. I think there's a hard limit of 50 but we are NOT reaching that. Nope nope nope! Likewise, I'm not going to try to handle a zero-parameter case. It returns a big red "Division by zero." as you likely see above, and that should be good enough.

Parameter count expression taken from https://www.mediawiki.org/wiki/Template:Number_of_defined_parameters .

God help us all. --GreytideSkye (talk) 17:28, 14 September 2024 (UTC)