<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2Fdavidwr%2Fexample</id>
	<title>Module:Sandbox/davidwr/example - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2Fdavidwr%2Fexample"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/davidwr/example&amp;action=history"/>
	<updated>2026-05-26T12:11:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/davidwr/example&amp;diff=146493&amp;oldid=prev</id>
		<title>imported&gt;Davidwr: test</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/davidwr/example&amp;diff=146493&amp;oldid=prev"/>
		<updated>2020-09-07T13:25:16Z</updated>

		<summary type="html">&lt;p&gt;test&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- &amp;lt;!-- surround LUA code with --&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; and --&amp;lt;/syntaxhightlight&amp;gt; --&amp;gt;&lt;br /&gt;
-- &amp;lt;!-- so it can be copied to &amp;quot;regular&amp;quot; Wikipedia pages --&amp;gt;&lt;br /&gt;
-- &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; &lt;br /&gt;
-- Cloned from [[Module:Example]] with edit history appended as a comment&lt;br /&gt;
--[[&lt;br /&gt;
version of 01:56, 30 July 2020‎ by Pppery https://en.wikipedia.org/w/index.php?title=Module:Example&amp;amp;oldid=970229354&lt;br /&gt;
&lt;br /&gt;
Edit history, for attribution:&lt;br /&gt;
    curprev 01:56, 30 July 2020‎ Pppery talk contribs‎ 4,681 bytes -1‎ Dummy edit to correct attribution: Author of previous edit is User:Szqecs undothank&lt;br /&gt;
    curprev 23:24, 29 July 2020‎ Pppery talk contribs‎ 4,682 bytes +2,161‎ Merging in Module:Basic example by User:Sqzecs undothank&lt;br /&gt;
    curprev 09:35, 14 April 2020‎ Serols talk contribs‎ m 2,521 bytes +2,521‎ Reverted edits by 2001:44C8:45C4:6836:1:0:CB99:7979 (talk) to last version by Pppery undothank Tag: Rollback&lt;br /&gt;
    curprev 09:34, 14 April 2020‎ 2001:44c8:45c4:6836:1:0:cb99:7979 talk‎ empty -2,521‎ ←Blanked the page undo Tags: Mobile edit Mobile web edit Blanking&lt;br /&gt;
    curprev 00:39, 22 February 2020‎ Pppery talk contribs‎ 2,521 bytes -6‎ undothank&lt;br /&gt;
    curprev 00:39, 22 February 2020‎ Pppery talk contribs‎ 2,527 bytes +518‎ Adding &amp;quot;count_fruit&amp;quot; from Module:BananasArgs; I&amp;#039;m going to stop here because none of the other example functions are actually used by help pages so I&amp;#039;m going to stop here undothank&lt;br /&gt;
    curprev 23:30, 21 February 2020‎ Pppery talk contribs‎ 2,009 bytes +506‎ Example module merge step two: First function of Module:BananasArgs (called &amp;quot;Hello&amp;quot; at the source), originally written by User:Dcoetzee (comments are my own addition) undothank&lt;br /&gt;
    curprev 20:07, 21 February 2020‎ Pppery talk contribs‎ 1,503 bytes +1,301‎ Step 1 of example module merge: Cp extensively commented code from Module:HelloWorld, originally written by Dragons flight undothank&lt;br /&gt;
    curprev 09:23, 1 December 2014‎ Sardanaphalus talk contribs‎ 202 bytes +202‎ Created per comment thank&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
-- end edit history of [[Module:Example]]&lt;br /&gt;
&lt;br /&gt;
local p = {};     --All lua modules on Wikipedia must begin by defining a variable &lt;br /&gt;
                    --that will hold their externally accessible functions.&lt;br /&gt;
                    --Such variables can have whatever name you want and may &lt;br /&gt;
                    --also contain various data as well as functions.&lt;br /&gt;
p.hello = function( frame )     --Add a function to &amp;quot;p&amp;quot;.  &lt;br /&gt;
                                        --Such functions are callable in Wikipedia&lt;br /&gt;
                                        --via the #invoke command.&lt;br /&gt;
                                        --&amp;quot;frame&amp;quot; will contain the data that Wikipedia&lt;br /&gt;
                                        --sends this function when it runs. &lt;br /&gt;
                                 -- &amp;#039;Hello&amp;#039; is a name of your choice. The same name needs to be referred to when the module is used.&lt;br /&gt;
    &lt;br /&gt;
    local str = &amp;quot;Hello World!&amp;quot;  --Declare a local variable and set it equal to&lt;br /&gt;
                                --&amp;quot;Hello World!&amp;quot;.  &lt;br /&gt;
    &lt;br /&gt;
    return str    --This tells us to quit this function and send the information in&lt;br /&gt;
                  --&amp;quot;str&amp;quot; back to Wikipedia.&lt;br /&gt;
    &lt;br /&gt;
end  -- end of the function &amp;quot;hello&amp;quot;&lt;br /&gt;
function p.hello_to(frame)		-- Add another function&lt;br /&gt;
	local name = frame.args[1]  -- To access arguments passed to a module, use `frame.args`&lt;br /&gt;
							    -- `frame.args[1]` refers to the first unnamed parameter&lt;br /&gt;
							    -- given to the module&lt;br /&gt;
	return &amp;quot;Hello, &amp;quot; .. tostring(name) .. &amp;quot;!&amp;quot;  -- `..` concatenates strings. This will return a customized&lt;br /&gt;
									 -- greeting depending on the name given, such as &amp;quot;Hello, Fred!&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
function p.count_fruit(frame)&lt;br /&gt;
	local num_bananas = frame.args.bananas -- Named arguments ({{#invoke:Example|count_fruit|foo=bar}}) are likewise &lt;br /&gt;
	local num_apples = frame.args.apples   -- accessed by indexing `frame.args` by name (`frame.args[&amp;quot;bananas&amp;quot;]`, or)&lt;br /&gt;
										   -- equivalently `frame.args.bananas`.&lt;br /&gt;
	return &amp;#039;I have &amp;#039; .. tostring(num_bananas) .. &amp;#039; bananas and &amp;#039; .. tostring(num_apples) .. &amp;#039; apples&amp;#039;&lt;br /&gt;
										   -- Like above, concatenate a bunch of strings together to produce&lt;br /&gt;
										   -- a sentence based on the arguments given.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function lucky(a, b) -- One can define custom functions for use. Here we define a function &amp;#039;lucky&amp;#039; that has two inputs a and b. The names are of your choice.&lt;br /&gt;
	if b == &amp;#039;yeah&amp;#039; then -- Condition: if b is the string &amp;#039;yeah&amp;#039;. Strings require quotes. Remember to include &amp;#039;then&amp;#039;.&lt;br /&gt;
		return a .. &amp;#039; is my lucky number.&amp;#039; -- Outputs &amp;#039;a is my lucky number.&amp;#039; if the above condition is met. The string concatenation operator is denoted by 2 dots.&lt;br /&gt;
	else -- If no conditions are met, i.e. if b is anything else, output specified on the next line.  &amp;#039;else&amp;#039; should not have &amp;#039;then&amp;#039;.&lt;br /&gt;
		return a -- Simply output a.&lt;br /&gt;
	end -- The &amp;#039;if&amp;#039; section should end with &amp;#039;end&amp;#039;.&lt;br /&gt;
end -- As should &amp;#039;function&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
function p.Name2(frame)&lt;br /&gt;
	-- The next five lines are mostly for convenience only and can be used as is for your module. The output conditions start on line 20.&lt;br /&gt;
	local pf = frame:getParent().args -- This line allows template parameters to be used in this code easily. The equal sign is used to define variables. &amp;#039;pf&amp;#039; can be replaced with a word of your choice.&lt;br /&gt;
	local f = frame.args -- This line allows parameters from {{#invoke:}} to be used easily. &amp;#039;f&amp;#039; can be replaced with a word of your choice.&lt;br /&gt;
	local M = f[1] or pf[1] -- f[1] and pf[1], which we just defined, refer to the first parameter. This line shortens them as &amp;#039;M&amp;#039; for convenience. You could use the original variable names.&lt;br /&gt;
	local m = f[2] or pf[2] -- Second shortened as &amp;#039;m&amp;#039;.&lt;br /&gt;
	local l = f.lucky or pf.lucky -- A named parameter &amp;#039;lucky&amp;#039; is shortend as l. Note that the syntax is different from unnamed parameters.&lt;br /&gt;
	if m == nil then -- If the second parameter is not used.&lt;br /&gt;
		return &amp;#039;Lonely&amp;#039; .. &amp;#039; f.IGNOREME1=&amp;#039; .. tostring(f.IGNOREME1) .. &amp;#039; f.IGNOREME2=&amp;#039; .. tostring(f.IGNOREME2) -- Outputs the string &amp;#039;Lonely&amp;#039; if the first condition is met.&lt;br /&gt;
	elseif M &amp;gt; m then -- If the first condition is not met, this line tests a second condition: if M is greater than m.&lt;br /&gt;
		return tostring(lucky(M - m, l)) .. &amp;#039; f[1]=&amp;#039; .. tostring(f[1]) .. &amp;#039; f[2]=&amp;#039;.. tostring(f[2]) .. &amp;#039; pf[1]=&amp;#039; .. tostring(pf[1]) .. &amp;#039; pf[2]=&amp;#039; .. tostring(pf[2]) .. &amp;#039; f.IGNOREME1=&amp;#039; .. tostring(f.IGNOREME1) .. &amp;#039; f.IGNOREME2=&amp;#039; .. tostring(f.IGNOREME2) -- If the condition is met, the difference is calculated and passed to the the self defined function along with l. The output depends on whether l is set to &amp;#039;yeah&amp;#039;.&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;Be positive!&amp;#039; .. &amp;#039; f[1]=&amp;#039; .. tostring(f[1]) .. &amp;#039; f[2]=&amp;#039;.. tostring(f[2]) .. &amp;#039; pf[1]=&amp;#039; .. tostring(pf[1]) .. &amp;#039; pf[2]=&amp;#039; .. tostring(pf[2])  .. &amp;#039; f.IGNOREME1=&amp;#039; .. tostring(f.IGNOREME1) .. &amp;#039; f.IGNOREME2=&amp;#039; .. tostring(f.IGNOREME2)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.transcludepage(frame)&lt;br /&gt;
	return mw.title.new(&amp;#039;User:Davidwr/sandbox3&amp;#039;):getContent()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p    --All modules end by returning the variable containing their functions to Wikipedia.&lt;br /&gt;
-- Now we can use this module by calling {{#invoke: Example | hello }},&lt;br /&gt;
-- {{#invoke: Example | hello_to | foo }}, or {{#invoke:Example|count_fruit|bananas=5|apples=6}}&lt;br /&gt;
-- Note that the first part of the invoke is the name of the Module&amp;#039;s wikipage,&lt;br /&gt;
-- and the second part is the name of one of the functions attached to the &lt;br /&gt;
-- variable that you returned.&lt;br /&gt;
&lt;br /&gt;
-- The &amp;quot;print&amp;quot; function is not allowed in Wikipedia.  All output is accomplished&lt;br /&gt;
-- via strings &amp;quot;returned&amp;quot; to Wikipedia.&lt;br /&gt;
&lt;br /&gt;
-- &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
-- &amp;lt;!-- surround LUA code with --&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; and --&amp;lt;/syntaxhightlight&amp;gt; --&amp;gt;&lt;br /&gt;
-- &amp;lt;!-- so it can be copied to &amp;quot;regular&amp;quot; Wikipedia pages --&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Davidwr</name></author>
	</entry>
</feed>