Module:RexxS

From Natural Philosophy Wiki
Jump to navigation Jump to search

-- -- 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 -- Pelicans 11.3.2007.jpg -- Pelicans 11.3.2007.jpg 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", "Mantis Nebraska.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 <switchtime> seconds - default is 4 -- -moz-transform:rotate(2deg);-webkit-transform:rotate(2deg); transform:rotate(2deg); -- -moz-transform:rotate(2deg);-webkit-transform:rotate(2deg); transform:rotate(2deg); 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 260 is a way of identifying preview mode. -- p.prevwarn = function(frame) local msg = frame.args.message if frame:preprocess( "260" ) == "" 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 -- How much did they pay for your life-story when they were filming Brazil? 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

return p