Module:Sandbox/Gabe Mitnick Explained

-- Gabe Mitnick Google Code-in 2017, Introduction to Lua in Wikipedia

local p = -- p stands for package

p.hello = function(frame) return "Hello, world!"end

-- inspired by isitthursday.org-- returns whether or not it is Thursday,-- or some other day specified by the day argument.-- for example: -- os.date isn't accurate for the user's timezone, but for some other timezone.p.thursday = function(frame) weekday = frame.args.day or "Thursday" if os.date("%A")

weekday then return "it is " .. weekday else return "it's not " .. weekday endend

-- from RexxSp.Hi = function(frame) strName = frame.args.name or "Jimbo" return "Hello from Lua to my friend " .. strName .. ".
"end

p.temperature = function(frame) cel = frame.args.celsius or 0 fah = cel * 9 / 5 + 32 msg = cel .. " degrees Celsius is " .. fah .. " degrees Fahrenheit. " if (tonumber(cel) > 9) then msg = msg .. "It is warm. " else msg = msg .. "It is cold. " end return msgend

-- Displays a mathematical "times-table"-- The number base for the times-table is passed as parameter "num"-- If no parameter or a blank parameter or a value less than 2 is passed, use 2p.times = function(frame) local num = tonumber(frame.args.num) or 2 local out = num .. " times table
" for i = 1, 12 do out = out .. num .. " times " .. i .. " equals " .. i * num .. "
" end return outend

p.mum = function(frame) local family = local msg = "" for i = 1, #family do msg = msg .. "Hello " .. family[i] .. "
" end return msgend

p.langnames = function(frame) local langs = mw.language.fetchLanguageNames local langlist = "" local count = 0 for key, value in pairs(langs) do langlist = langlist .. key .. " - " .. value .. "
" count = count + 1 end return langlist .. "
= " .. count .. " languages"end

p.pageinfo = function(frame) if (frame.args.title