<?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%2FPelagic%2F01</id>
	<title>Module:Sandbox/Pelagic/01 - 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%2FPelagic%2F01"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Pelagic/01&amp;action=history"/>
	<updated>2026-04-21T10:25:06Z</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/Pelagic/01&amp;diff=145972&amp;oldid=prev</id>
		<title>imported&gt;Pppery: Pppery moved page Module:Pelagic01 to Module:Sandbox/Pelagic/01 without leaving a redirect: Naming convention for test modules</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Pelagic/01&amp;diff=145972&amp;oldid=prev"/>
		<updated>2021-06-10T12:37:13Z</updated>

		<summary type="html">&lt;p&gt;Pppery moved page &lt;a href=&quot;/index.php?title=Module:Pelagic01&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Module:Pelagic01 (page does not exist)&quot;&gt;Module:Pelagic01&lt;/a&gt; to &lt;a href=&quot;/research/Module:Sandbox/Pelagic/01&quot; title=&quot;Module:Sandbox/Pelagic/01&quot;&gt;Module:Sandbox/Pelagic/01&lt;/a&gt; without leaving a redirect: Naming convention for test modules&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Baby steps with Scribunto and Lua&lt;br /&gt;
&lt;br /&gt;
--[[ Things I&amp;#039;m unsure of or probably doing wrong: &lt;br /&gt;
* Convention for per-user collections of modules, &lt;br /&gt;
  could I use subpages like Module:Pelagic/Test01 ? &lt;br /&gt;
* Haven&amp;#039;t read the coding conventions yet. &lt;br /&gt;
** Caps? camelCase? underscores?&lt;br /&gt;
* Existing general utility modules? (as opposed to template-specific modules)&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
--[[ Annoyances:&lt;br /&gt;
* iOS keyboard automatically converts - - to —, &lt;br /&gt;
  it would be nice to have a button to comment/uncomment a line. &lt;br /&gt;
* Hardware keyboard on iOS types curly quotes not straight quotes. &lt;br /&gt;
* Tap and drag on a touchscreen selects characters and &lt;br /&gt;
  can&amp;#039;t be used to fine-position cursor.&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
--[[ Nice features:&lt;br /&gt;
* Editor starts next line at same indent level, &lt;br /&gt;
  automatically outdents when you type &amp;quot;end&amp;quot;.&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local p = {} -- initialize a table to hold the functions&lt;br /&gt;
&lt;br /&gt;
function p.create_deck(from_number, to_number)&lt;br /&gt;
	local ranks = { &amp;#039;A&amp;#039;, &amp;#039;2&amp;#039;, &amp;#039;3&amp;#039;, &amp;#039;4&amp;#039;, &amp;#039;5&amp;#039;, &amp;#039;6&amp;#039;, &amp;#039;7&amp;#039;, &amp;#039;8&amp;#039;, &amp;#039;9&amp;#039;, &amp;#039;10&amp;#039;, &lt;br /&gt;
		&amp;#039;J&amp;#039;, &amp;#039;Q&amp;#039;, &amp;#039;K&amp;#039;, &amp;#039;A&amp;#039; } -- sequence (array) of rank strings&lt;br /&gt;
	local suits = { &amp;#039;♥&amp;#039;, &amp;#039;♦&amp;#039;, &amp;#039;♠&amp;#039;, &amp;#039;♣&amp;#039; } -- same for suits&lt;br /&gt;
	local specials = { &amp;#039;joker&amp;#039;, &amp;#039;joker&amp;#039; } -- two jokers&lt;br /&gt;
	local d = { } -- the deck&lt;br /&gt;
	-- mw.logObject(ranks)&lt;br /&gt;
	-- mw.log(table.concat(ranks,&amp;quot;&amp;quot;))&lt;br /&gt;
	 &lt;br /&gt;
	-- default to a standard 52-card deck, aces low&lt;br /&gt;
	local a = from_number or 1&lt;br /&gt;
	local b = to_number or 13&lt;br /&gt;
	local step = 1&lt;br /&gt;
	if b == 14 and a == 1 then a = 2 end -- don&amp;#039;t double up on aces&lt;br /&gt;
	if b &amp;lt; a then step = -1 end&lt;br /&gt;
&lt;br /&gt;
	for r = a, b, step do&lt;br /&gt;
		for s = 1, 4 do&lt;br /&gt;
			c = ranks[r] .. suits[s] -- concat rank+suit&lt;br /&gt;
			-- mw.log(c)&lt;br /&gt;
			&lt;br /&gt;
			-- I was going to implement thedeck as a set&lt;br /&gt;
			-- d[c] = true -- insert the card in the deck&lt;br /&gt;
			-- but choosing a random card to draw was hard&lt;br /&gt;
			&lt;br /&gt;
			table.insert(d, c)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- mw.logObject(d)&lt;br /&gt;
	mw.log(table.concat(d,&amp;#039;,&amp;#039;)) -- This doesn&amp;#039;t work with a set, &lt;br /&gt;
	--  even if I set the strings as values.&lt;br /&gt;
	-- Looks like concat only works with sequences.&lt;br /&gt;
	return d&lt;br /&gt;
end&lt;br /&gt;
-- to-do: pass custom rank and suit and specials as params, pass params for start and end ranks&lt;br /&gt;
function p.create_deck_doc() &lt;br /&gt;
	return [[&lt;br /&gt;
	create_deck() makes a deck of cards as a Lua sequence.&lt;br /&gt;
	from_number and to_number can be in the range 1 (low ace) to 14 (high ace).&lt;br /&gt;
	]]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.draw_card(deck)&lt;br /&gt;
	-- n = math.random(# deck)&lt;br /&gt;
	-- mw.log(n)&lt;br /&gt;
	-- c = table.remove(deck, n)&lt;br /&gt;
	-- mw.log(c)&lt;br /&gt;
	-- return c&lt;br /&gt;
	return table.remove(deck, math.random(# deck))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.draw_cards(deck, count)&lt;br /&gt;
	local cards = {}&lt;br /&gt;
	for i = 1, count do&lt;br /&gt;
		table.insert(cards,p.draw_card(deck))&lt;br /&gt;
	end&lt;br /&gt;
	return cards&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.hand(number)&lt;br /&gt;
	math.randomseed(os.time())&lt;br /&gt;
	local d = p.create_deck()&lt;br /&gt;
	return p.draw_cards(d, number)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.hand_of_cards(frame)&lt;br /&gt;
	a=frame.args&lt;br /&gt;
	number = a[&amp;quot;number&amp;quot;] or a[1]&lt;br /&gt;
	list_separator = a[&amp;quot;list_separator&amp;quot;]&lt;br /&gt;
	return table.concat(p.hand(number), list_separator or &amp;#039; &amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p -- export the table&lt;/div&gt;</summary>
		<author><name>imported&gt;Pppery</name></author>
	</entry>
</feed>