Module:Sandbox/MjolnirPants
Appearance
local getArgs = require('Module:Arguments').getArgs
p = {}
--Hurls a randomly generated, nonsensical insult.
--Invoke using:
--{{#invoke:MjolnirPants|NonsenseNameCaller}}
p.NonsenseNameCaller = function()
--set up the syntax
local syntaxes = {
"You are a _1_ _2_.",
"Go away, you _1_ _2_.",
"You _1_ _2_.",
"Have you always been so _1_, you _2_?",
"Listen, _2_, stop being so _1_."
}
local syntaxMax = 5
--set up the adjective
local adjectives = {
"bildering",
"globulish",
"pustulating",
"gilberous",
"blartous"
}
local adjMax = 5
--set up the noun
local nouns = {
"bustule",
"narklaholic",
"gandypuffer",
"dorkleragger",
"plonk"
}
local nounMax = 5
--pick the three elements
local seed = math.floor(os.time())
math.randomseed(seed)
local syntax = syntaxes[math.random(syntaxMax)]
local adjective = adjectives[math.random(adjMax)]
local noun = nouns[math.random(nounMax)]
--make the insult
local insult = string.gsub(syntax, "_1_", adjective)
insult = string.gsub(insult, "_2_", noun)
return insult
end
p.GraphSelector = function()
--initialize the random number genny
local seed = math.floor(os.time())
math.randomseed(seed)
--Get the X and Y offsets
local xOffset = math.random(10) * 250
local yOffset = math.random(10) * 250
--Concatenate the string and return it
local resString = "{{CSS image drop|Image = ECDF-100.png|bSize = 2500|cWidth = 250|cHeight = 250|oTop = " .. xOffset .. "|oLeft = " .. yOffset .. "|Location = left|Description = The blue step function graph shows an empirical distribution function. The grey bars represent the observations in the sample corresponding to the sample’s empirical distribution function, and the green curve, which asymptotically approaches a height of 1 without reaching it, is the true cumulative distribution function.}}"
return resString
end
p.GraphPickerX = function()
local seed = math.floor(os.time())
math.randomseed(seed)
--Get the X and Y offsets
local xOffset = math.random(0, 9) * 250
return xOffset
end
p.GraphPickerY = function()
local seed = math.floor(os.time()) + 1 -- just to be sure
math.randomseed(seed)
--Get the X and Y offsets
local yOffset = math.random(0, 9) * 250
return yOffset
end
function p.test(frame)
--return mw.title.getCurrentTitle():getContent()
local args = getArgs(frame)
local foo = "foobarbizban"
local i, j = string.find(foo, "bar")
local ret = "i:" .. i .. " j:" .. j
i, j = string.find(foo, "chocolate")
ret = ret .. " i2:" .. i " j2:" .. j
return ret
end
function p.PingRFCUsers(frame)
local args = getArgs(frame)
return p._PingRFCUsers(args)
end
function p._PingRFCUsers(args)
local pageSource = mw.title.getCurrentTitle():getContent()
local users = {}
local ii = 1
local i, j = string.find(pageSource, "==" .. args[1])
pageSource = string.sub(pageSource, i + string.len(args[1]) + 4)
i, j = string.find(pageSource, "==")
pageSource = string.sub(pageSource, 1, i - 1)
i, j = string.find(pageSource, "%[%[User:")
local uName = ""
local k, l, m, n = i + 1
local cat = ""
while i ~= nil and ii < 2 do
i, j = string.find(pageSource, "%[%[User:")
k, l = string.find(pageSource, "|")
m, n = string.find(pageSource, "%]%]")
if (m > k) then
uName = string.sub(pageSource, j, k - 1)
pageSource = string.sub(pageSource, k)
else
uName = string.sub(pageSource, j, m - 1)
pageSource = string.sub(pageSource, m)
end
users[ii] = uName
cat = cat .. "\r\nFound Name: " .. uName
ii = ii + 1
end
local ret = "{{u|"
for _, v in ipairs(users) do
ret = ret .. v .. "|"
end
--return string.sub(ret, 1, string.len(ret) - 1) .. "}}"
return pageSource.. "\r\nuser1:" .. users[1] .. "\r\ni:" .. i .. " j:" .. j .. " k:" .. k .. " l:" .. l .. " m:" .. m .. " n:" .. n
end
return p