Jump to content

Module:Sandbox/Bjornskjald

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Bjornskjald (talk | contribs) at 07:54, 26 October 2018 (task 3: step 3). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Bjornskjald, Google Code-in, Introduction to Lua in Wikipedia
-- Lua Task 2 - Working with modules

local p = {} -- p stands for package

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

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

p.temperature = function(frame)
	cel = frame.args.celsius
	fah = cel * 9 / 5 + 32
	return cel .. " degrees Celsius is " .. fah .. " degrees Fahrenheit."
end

return p