Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Schjessu wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
LE SCHOOL SYSTEMS BLOCKING OUR GOOD WIKI! 1984 1984 1984!
mayb ill do smth abt it
Editing
Module
:
Random/doc
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Once you make an edit, a temporary account will be created for you.
Learn more
.
Log in
or
create an account
to continue receiving notifications after this account expires, and to access other features.
Anti-spam check. Do
not
fill this in!
{{high-use}} {{module rating|protected}} {{Lua|Module:List|Module:Yesno}} This module contains a number of functions that use random numbers. It can output random numbers, select a random item from a list, and reorder lists randomly. The randomly reordered lists can be output inline, or as various types of ordered and unordered lists. The available functions are outlined in more detail below. == Number == The <code>number</code> function outputs a random number. {{#invoke:random|number|''m''|''n''|same=''yes''}} The arguments <code>m</code> and <code>n</code> may be omitted, but if specified must be convertible to integers. * With no arguments, returns a real number in the range <math>[0,1)</math>. * With one argument, returns an integer in the range <math>[1,m]</math>, or, if <code>''m''</code> is negative, <math>(-m,0]</math>. If <code>''m''</code> is equal to 0 or 1, returns 1 (or 0 if <math>m=-1</math>). * With two arguments, returns an integer in the range <math>[m,n]</math>. <code>''m''</code> and <code>''n''</code> can be either positive or negative. If <code>''m''</code> is greater than <code>''n''</code>, returns an integer in the range <math>[n,m]</math> instead. * If the {{para|same}} parameter is set to "yes", "y", "true", or "1", the same random number is returned for each module call on a given page. '''Examples''' <small>({{purge|refresh|anchor=Number}})</small> * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|number}}</syntaxhighlight> → {{#invoke:random|number}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|number|100}}</syntaxhighlight> → {{#invoke:random|number|100}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|number|-100|-50}}</syntaxhighlight> → {{#invoke:random|number|-100|-50}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|number|100|same=yes}}</syntaxhighlight> → {{#invoke:random|number|100|same=yes}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|number|100|same=yes}}</syntaxhighlight> → {{#invoke:random|number|100|same=yes}} <small>The documentation for this function is partly taken from the [[mw:Extension:Scribunto/Lua reference manual#math.random|Scribunto Lua reference manual]], which is in turn based on the [http://www.lua.org/manual/5.1/index.html Lua 5.1 Reference Manual], available under the [[MIT License]].</small> == Date == The <code>date</code> function outputs a random date. {{#invoke:random|date|''timestamp1''|''timestamp2''|format=''date format''|same=''yes''}} * If no timestamp arguments are specified, the module outputs a random date in the current year. * If <code>''timestamp1''</code> and <code>''timestamp2''</code> are specified, the module outputs a random date between the two timestamps. <code>''timestamp1''</code> must be earlier than <code>''timestamp2''</code>. * If only <code>''timestamp1''</code>is specified, the module outputs a random date between the [[Unix epoch]] (1 Jan 1970) and the timestamp. <code>''timestamp1''</code> must not be earlier than 1 Jan 1970. * Formatting can be specified with the {{para|format}} parameter. The default formatting is "hh:mm, DD Month YYYY (UTC)" (the same as the default Wikipedia timestamp). * The timestamps and the {{para|format}} parameter accept values compatible with the [[mw:Help:Extension:ParserFunctions##time|#time parser function]]. Please see the #time documentation for the full range of possible input values and formatting options. * If the {{para|same}} parameter is set to "yes", "y", "true", or "1", the same date is returned for each module call on a given page. '''Examples''' <small>({{purge|refresh|anchor=Date}})</small> * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|date}}</syntaxhighlight> → {{#invoke:random|date}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|date|format=F j}}</syntaxhighlight> → {{#invoke:random|date|format=F j}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|date|1 Jan 1980|31 Dec 1999}}</syntaxhighlight> → {{#invoke:random|date|1 Jan 1980|31 Dec 1999}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|date|1st January 1500|1st January 3000|format=g:i a, l d M Y}}</syntaxhighlight> → {{#invoke:random|date|1st January 1500|1st January 3000|format=g:i a, l d M Y}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|date|1970/06/01}}</syntaxhighlight> → {{#invoke:random|date|1970/06/01}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|date|same=yes}}</syntaxhighlight> → {{#invoke:random|date|same=yes}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|date|same=yes}}</syntaxhighlight> → {{#invoke:random|date|same=yes}} == Item == The <code>item</code> function outputs a random item from a list. {{#invoke:random|item|''list item 1''|''list item 2''|''list item 3''|...|same=''yes''}} If the {{para|same}} parameter is set to "yes", "y", "true", or "1", the same item is returned for each module call on a given page. '''Example''' <small>({{purge|refresh|anchor=Item}})</small> * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|item|egg|beans|sausage|bacon|spam}}</syntaxhighlight> → {{#invoke:random|item|egg|beans|sausage|bacon|spam}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|item|egg|beans|sausage|bacon|spam|same=yes}}</syntaxhighlight> → {{#invoke:random|item|egg|beans|sausage|bacon|spam|same=yes}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|item|egg|beans|sausage|bacon|spam|same=yes}}</syntaxhighlight> → {{#invoke:random|item|egg|beans|sausage|bacon|spam|same=yes}} Setting "same" will make the template select the same number item from each list, even if the things in them are different. * <syntaxhighlight lang="wikitext">My {{#invoke:random|item|egg |bean |sausage |bacon |spam |same=yes}} is {{#invoke:random|item|quail |pinto |kielbasa |canadian |spammy|same=yes}} and my {{#invoke:random|item|blegg |blean |blausage |blacon |blam |same=yes}} is {{#invoke:random|item|blail |blinto|blielbasa|blanadian|blammy|same=yes}}</syntaxhighlight> → My {{#invoke:random|item|egg |bean |sausage |bacon |spam |same=yes}} is {{#invoke:random|item|quail |pinto |kielbasa |canadian |spammy|same=yes}} and my {{#invoke:random|item|blegg |blean |blausage |blacon |blam |same=yes}} is {{#invoke:random|item|blail |blinto|blielbasa|blanadian|blammy|same=yes}}. == List == The <code>list</code> function outputs a list in a random order. {{#invoke:random|list|''list item 1''|''list item 2''|''list item 3''|...|sep=''separator''|limit=''number of items to display''|same=''yes''}} '''Named parameters''' * {{para|sep}} or {{para|separator}} - an optional separator for the list items. Some values are special; see the table below. * {{para|limit}} - the maximum number of list items to display. The lowest possible is 0 and the highest possible is the length of the list. * {{para|same}} - if this is set to "yes", "y", "true", or "1", the list order is the same for each module call on a given page. {| class="wikitable" |+ Possible separator values |- ! Code !! Output |- | <code>dot</code> || {{int:dot-separator}} |- | <code>pipe</code> || {{int:pipe-separator}} |- | <code>comma</code> || {{int:comma-separator}} |- | <code>tpt-languages</code> || {{int:tpt-languages-separator}} |- | <code>space</code> || ''a space'' |- | <code>newline</code> || ''a newline character'' |- | ''any other value'' || ''other values are used without modification'' |} You cannot input spaces directly to the {{para|sep}} parameter due to limitations in MediaWiki's template syntax. However, it is possible to work around this by using [[HTML entities]]. You can use <code>&#32;</code> to represent a normal space, and <code>&nbsp;</code> to represent a [[non-breaking space]]. '''Examples''' <small>({{purge|refresh|anchor=List}})</small> * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|list|egg|beans|sausage|bacon|spam}}</syntaxhighlight> → {{#invoke:random|list|egg|beans|sausage|bacon|spam}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=dot}}</syntaxhighlight> → {{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=dot}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=space}}</syntaxhighlight> → {{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=space}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=;&#32;}}</syntaxhighlight> → {{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=; }} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=foo}}</syntaxhighlight> → {{#invoke:random|list|egg|beans|sausage|bacon|spam|sep=foo}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|list|egg|beans|sausage|bacon|spam|limit=3}}</syntaxhighlight> → {{#invoke:random|list|egg|beans|sausage|bacon|spam|limit=3}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|list|egg|beans|sausage|bacon|spam|same=yes}}</syntaxhighlight> → {{#invoke:random|list|egg|beans|sausage|bacon|spam|same=yes}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|list|egg|beans|sausage|bacon|spam|same=yes}}</syntaxhighlight> → {{#invoke:random|list|egg|beans|sausage|bacon|spam|same=yes}} == Text list == The <code>text_list</code> function outputs a list in a random order, text-style. In other words, it is like the <code>list</code> function, but with a different separator before the last item. {{#invoke:random|text_list|''list item 1''|''list item 2''|''list item 3''|...|sep=''separator''|conj=''conjunction''|limit=''number of items to display''|same=''yes''}} The separator can be specified with either the {{para|sep}} or {{para|separator}} parameters; its default value is "{{int:comma-separator}}". The conjunction can be specified with either the {{para|conj}} or {{para|conjunction}} parameters; its default value is " and ". The separator and the conjunction can be specified with the same values as the separator in the [[#List|list function]]. The maximum number of list items to display can be set with the {{para|limit}} parameter. The lowest possible is 0 and the highest possible is the length of the list. If the {{para|same}} parameter is set to "yes", "y", "true", or "1", the list order is the same for each module call on a given page. '''Examples''' <small>({{purge|refresh|anchor=Text list}})</small> * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|text_list|egg|beans|sausage|bacon|spam}}</syntaxhighlight> → {{#invoke:random|text_list|egg|beans|sausage|bacon|spam}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|text_list|egg|beans|sausage|bacon|spam|sep=;&#32;}}</syntaxhighlight> → {{#invoke:random|text_list|egg|beans|sausage|bacon|spam|sep=; }} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|text_list|egg|beans|sausage|bacon|spam|sep=;&#32;|conj=&#32;or&#32;}}</syntaxhighlight> → {{#invoke:random|text_list|egg|beans|sausage|bacon|spam|sep=; |conj= or }} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|text_list|egg|beans|sausage|bacon|spam|limit=3}}</syntaxhighlight> → {{#invoke:random|text_list|egg|beans|sausage|bacon|spam|limit=3}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|text_list|egg|beans|sausage|bacon|spam|same=yes}}</syntaxhighlight> → {{#invoke:random|text_list|egg|beans|sausage|bacon|spam|same=yes}} * <syntaxhighlight lang="wikitext" inline>{{#invoke:random|text_list|egg|beans|sausage|bacon|spam|same=yes}}</syntaxhighlight> → {{#invoke:random|text_list|egg|beans|sausage|bacon|spam|same=yes}} == HTML lists == If you wish to output an HTML list in a random order, you can choose between five different functions: <code>bulleted_list</code>, <code>unbulleted_list</code>, <code>horizontal_list</code>, <code>ordered_list</code>, and <code>horizontal_ordered_list</code>. These functions all use [[Module:List]]. {| class="wikitable" |- ! Function name ! Produces ! Example code ! Example output <small>({{purge|refresh|anchor=HTML lists}})</small> |- | <code>bulleted_list</code> | Bulleted lists | <syntaxhighlight lang="wikitext" inline>{{#invoke:random|bulleted_list|egg|sausage|spam}}</syntaxhighlight> | {{#invoke:random|bulleted_list|egg|sausage|spam}} |- | <code>unbulleted_list</code> | Unbulleted lists | <syntaxhighlight lang="wikitext" inline>{{#invoke:random|unbulleted_list|egg|sausage|spam}}</syntaxhighlight> | {{#invoke:random|unbulleted_list|egg|sausage|spam}} |- | <code>horizontal_list</code> | Horizontal bulleted lists | <syntaxhighlight lang="wikitext" inline>{{#invoke:random|horizontal_list|egg|sausage|spam}}</syntaxhighlight> | {{#invoke:random|horizontal_list|egg|sausage|spam}} |- | <code>ordered_list</code> | Ordered lists (numbered lists and alphabetical lists) | <syntaxhighlight lang="wikitext" inline>{{#invoke:random|ordered_list|egg|sausage|spam}}</syntaxhighlight> | {{#invoke:random|ordered_list|egg|sausage|spam}} |- | <code>horizontal_ordered_list</code> | Horizontal ordered lists | <syntaxhighlight lang="wikitext" inline>{{#invoke:random|horizontal_ordered_list|egg|sausage|spam}}</syntaxhighlight> | {{#invoke:random|horizontal_ordered_list|egg|sausage|spam}} |} ; Basic usage {{#invoke:random|''function''|''list item 1''|''list item 2''|''list item 3''|...|limit=''number of items to display''|same=''yes''}} ; All parameters {{pre| <nowiki>{{</nowiki>#invoke:random<nowiki>|</nowiki>''function'' <nowiki>|</nowiki>''first item''<nowiki>|</nowiki>''second item''<nowiki>|</nowiki>''third item''<nowiki>|</nowiki>... <nowiki>|start = </nowiki>''start number for ordered lists'' <nowiki>|type = </nowiki>''type of marker for ordered lists'' <nowiki>|list_style_type = </nowiki>''type of marker for ordered lists (uses CSS)'' <nowiki>|class = </nowiki>''class'' <nowiki>|style = </nowiki>''style'' <nowiki>|list_style = </nowiki>''style for the list'' <nowiki>|item_style = </nowiki>''style for all list items'' <nowiki>|item_style1 = </nowiki>''style for the first list item''<nowiki> |item_style2 = </nowiki>''style for the second list item''<nowiki> |</nowiki>... <nowiki>|indent = </nowiki>''indent for horizontal lists'' <nowiki>}}</nowiki> }} The maximum number of list items to display can be set with the {{para|limit}} parameter. The lowest possible is 0 and the highest possible is the length of the list. If the {{para|same}} parameter is set to "yes", "y", "true", or "1", the list order is the same for each module call on a given page. Please see [[Module:List]] for a full explanation of the other parameters.
Summary:
Please note that all contributions to Schjessu wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Schjessu wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Pages included on this page:
Template:High-use
(
edit
)
Template:Hlist/styles.css
(
edit
)
Template:Lua
(
edit
)
Template:Module rating
(
edit
)
Template:Para
(
edit
)
Template:Plainlist/styles.css
(
edit
)
Template:Pre
(
edit
)
Template:Purge
(
edit
)
Module:List
(
edit
)
Module:Random
(
edit
)
Module:TableTools
(
edit
)
Module:Yesno
(
edit
)
Search
Search
Editing
Module
:
Random/doc
Add topic