Module:RexxS

-- -- Lua functions for personal use --

p = {}

-- carousel returns one of a list of image filenames -- the index of the one chosen increments every 'switchsecs' -- which is a parameter giving the number of seconds between switches -- 3600 would switch every hour -- 43200 would be every 12 hours (the default) -- 86400 would be daily -- -- for 12 hours between switches p.carousel = function(frame) local switchtime = tonumber(frame.args.switchsecs) or 43200 if switchtime < 1 then switchtime = 43200 end local imgs = { "Pelicans 11.3.2007.jpg", "Great Blue Heron and immature Bald Eagle on the Platte River.jpg", "Green Heron4.jpg", "Canada Goose mating ritual2.jpg", "Flock of Cedar Waxwings3.jpg", "Lightning 7.11.2008.jpg", "Ursus americanus.jpg", "Stone Creek Nebraska.jpg", "Grus canadensis2.jpg", "Scaphirhynchus platorynchus 6.14.2014a.jpg", "Bison Bull in Nebraska.jpg", "Horses and thunderstorm1.jpg", "Lillypads at Desoto.jpg", "Steamboat Geyser.jpg", "Lake view from Beartooth Pass.jpg", "Tetons from Togwotee Pass.jpg", "Inspiration Point.jpg", "Flowers b grow to 6 feet.jpg", "Storm Front2.jpg" }	local numimgs = #imgs local now = math.floor(os.time/switchtime) local idx = now % numimgs +1 return imgs[idx] end

-- wobble returns CSS which rotates the container -- possible angles are -4, -2, 0, 2, 4 degrees -- a different angle is selected every seconds - default is 4 -- -- for 4 seconds between switches p.wobble = function(frame) local switchtime = tonumber(frame.args.switchsecs) or 4 if switchtime < 1 then switchtime = 4 end local now = math.floor(os.time/switchtime) local angle = 2 * (now % 5 -2 ) return "-moz-transform:rotate(" .. angle .. "deg);-webkit-transform:rotate(" .. angle .. "deg); transform:rotate(" .. angle .. "deg);" end

-- prevwarn returns a hatnote-style warning message in red -- the customisable text of the warning is passed in the parameter 'message' -- it only returns the warning in preview mode -- note that a blank is a way of identifying preview mode. -- p.prevwarn = function(frame) local msg = frame.args.message if frame:preprocess( "" ) == "" then return ' Warning: ' .. msg .. ' (this message is shown only in preview). '	end end

-- sandyrock returns a pseudo-random message inline -- the style is customisable with the 'style' parameter -- other messages may be added or substituted, just separate with a comma -- p.sandyrock = function(frame) local style = frame.args.style local msgs = { "You make Vogons look frivolous", "You're the poster-child for the phrase 'bureaucratic nightmare'", "How much did they pay for your life-story when they were filming Brazil?" }	local idx = os.time % #msgs +1 return ' ' .. msgs[idx] .. ' ' end

-- getLink returns the label for a Qid linked to the article p.getLink = function(frame) local itemID = mw.text.trim(frame.args[1] or "") if itemID == "" then return end local sitelink = mw.wikibase.sitelink(itemID) local label = mw.wikibase.label(itemID) if not label then label = itemID end if sitelink then return "" .. label .. "" else return label end end

-- getAT returns the article title for a Qid p.getAT = function(frame) local itemID = mw.text.trim(frame.args[1] or "") if itemID == "" then return end return mw.wikibase.sitelink(itemID) end

return p