Module:Sandbox/econterms

-- Training at Wikimania 2019 -- this is a comment

p = {}   -- I think this is a Lua "table"

-- we could have seveal functions, each of which is an entry in the table p -- below, the syntax "function p.CleverName(frame)"" means the same as "p.Hi=function(frame)"

function p.CleverName(frame) return "Hello world." end

-- the "frame" object containts an object called args. frame.args is a table -- frames.arg.name is a string explicitly created at the other may be the user's name p.Hi = function(frame) strName = frame.args.name or "Jimbo" -- uses "Jimbo" if name was nil; that is, wasn't specified 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 = "The temperature's over 10" --  else --       msg = "The temperature's not over 10" --   end return fah -- .. msg end

-- an example with a loop 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

return p