Difference between revisions of "User:Kevincox/Random"

From Team Fortress Wiki
Jump to: navigation, search
m (Here's my suggestion)
m (Although I don't understand why you've added 2... you can just use parenthesis.)
 
(11 intermediate revisions by one other user not shown)
Line 1: Line 1:
Template Method
+
<includeonly>
 +
{{{ {{#expr: ( {{#time:U}} mod {{{1}}} ) + 2 }} }}}
 +
</includeonly>
 +
<noinclude>
  
{{#expr: {{#time:U}}/11}}
+
{{Doc begin}}
{{#switch: {{#expr:{{#time:U}} mod 3}}
+
 
| 1 = Choice 1
+
This template will select a random item from the list of items passed in and "return" it.  Effectively including one of the passed in items at random.
| 2 = Choice 2
+
 
| 3 = Choice 3
+
=== Syntax ===
 +
 
 +
<nowiki>
 +
{{User:Kevincox/Random|3
 +
|{{Quotation|'''The Medic''', making preparations|... Let's go practice medicine.|sound=LetsGoPracticeMedicine.wav}}
 +
|{{Quotation|'''Kevin Cox''', writing a template|Please work!}}
 +
|{{Quotation|'''Kevin Cox''', running out of things to say.|Ummm...}}
 +
}}
 +
</nowiki>
 +
 
 +
The first argument is the number of items and the rest of the arguments are the items themselves.  Below is the above example.
 +
 
 +
{{User:Kevincox/Random|3
 +
|{{Quotation|'''The Medic''', making preparations|... Let's go practice medicine.|sound=LetsGoPracticeMedicine.wav}}
 +
|{{Quotation|'''Kevin Cox''', writing a template|Please work!.}}
 +
|{{Quotation|'''Kevin Cox''', running out of things to say.|Ummm...}}
 
}}
 
}}
  
{{#random:1
+
=== Updating Notes ===
| {{Quotation|'''The Medic''', making preparations|... Let's go practice medicine.|sound=LetsGoPracticeMedicine.wav}}
+
Because Mediawiki caches pages to improve performance the template will only update when the page is purged, this happens when a page, or any templates on a page are edited. The cache is also invalidated and purged every <code>$wgParserCacheExpireTime</code> seconds (the default is 24h) see [https://www.mediawiki.org/wiki/Manual:Configuration_settings#Parser_Cache this page] for more info.
| Quote 2
 
| Quote 3
 
}}
 
  
Tag Method
+
</noinclude>
<random count="1">
 
<item>Quote 1</item>
 
<item>Quote 2</item>
 
<item>Quote 3</item>
 
</random>
 

Latest revision as of 17:48, 28 November 2012


Documentation for Kevincox/Random


This template will select a random item from the list of items passed in and "return" it. Effectively including one of the passed in items at random.

Syntax

 {{User:Kevincox/Random|3
 |{{Quotation|'''The Medic''', making preparations|... Let's go practice medicine.|sound=LetsGoPracticeMedicine.wav}}
 |{{Quotation|'''Kevin Cox''', writing a template|Please work!}}
 |{{Quotation|'''Kevin Cox''', running out of things to say.|Ummm...}}
 }}
 

The first argument is the number of items and the rest of the arguments are the items themselves. Below is the above example.


Please work!.
Kevin Cox, writing a template



Updating Notes

Because Mediawiki caches pages to improve performance the template will only update when the page is purged, this happens when a page, or any templates on a page are edited. The cache is also invalidated and purged every $wgParserCacheExpireTime seconds (the default is 24h) see this page for more info.