Module:Sandbox/Tonina Zhelyazkova (WMDE)

--practicng lua

p = {}

function p.test(frame) return 'hello world' end

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

function p.temperature(frame) cel = tonumber(frame.args.celsius) or 0 fah = cel * 9 / 5 + 32 if cel >= 10 then msg = " it is warm" else msg = " it is cold" end return "Oh, " .. msg .. ". " end

p.times = function(frame) local num = tonumber( frame.args.num ) or 2 local out = "Times table " for i = 1, 10 do out = out .. i * num .. " "	end return out end

p.mum = function(frame) local family = {"Dad", "Mum", "Uncle Stan", "Aunty Elsie", "Brian", "Tonina", "Zhelyazkova", "Jane Doe"} local msg = "" for i = 1, #family do msg = msg .. "Hello " .. family[i] .. " "	end return msg end

p.sentence = function(frame) local str = frame.args.words or "" return string.upper(string.sub(str, 1, 1)) .. string.sub(str, 2) end

p.unpackdate = function(frame) local dmydate = frame.args.dmydate or "" local day, month, year = string.match(dmydate, "(%d+) (%w+) (%d+)") return "Year = " .. year .. " Day = " .. day .. " Month = " .. month end

return p