imported>Sathuheb No edit summary |
(No difference)
|
Latest revision as of 13:00, 16 January 2018
Documentation for this module may be created at Module:Sandbox/Sathuheb/doc
-- Sathuheb Google Code-in 2017, Introduction to Lua in Wikipedia
-- Task: Create your own Lua module on English Wikipedia. Google Code-in 2017, Introduction to Lua in Wikipedia
-- This is the table which must hold the functions to be returned.
-- This table will have only one function as a part of this task,
-- the function to return "Hello, world!".
local p = {}
-- The function to return "Hello, world!".
function p.hello(frame)
-- Return the message.
return "Hello, world!";
-- end of function definition.
end
-- Task: Pass information to your Lua module. Google Code-in 2017, Introduction to Lua in Wikipedia
-- This function returns a string greeting to the name specified
-- by the arguments of the frame.
p.Hi = function(frame)
-- The name of the person.
strName = frame.args.name or "Jimbo"
-- Returns the message.
return "Hello from Lua to my friend " .. strName .. ".<br>"
-- end of function definition.
end
-- Task: Perform calculations in Lua. Google Code-in 2017, Introduction to Lua in Wikipedia
-- This function takes an argument 'celsius', a temperature on the
-- Centigrade scale and returns a string expressing the argument
-- and the corresponding temperature on the Fahrenheit scale.
p.temperature = function(frame)
-- The temperature on the centigrade scale.
cel = frame.args.celsius
-- The corresponding temperature on the Fahrenheit scale.
fah = cel * 9 / 5 + 32
-- Returns the message.
return cel .. " degree Celsius is " .. fah .. " degree Fahrenheit"
-- end of function definition.
end
-- Returns the table of functions.
return p