Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Sathuheb
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- 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
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Sathuheb/doc
(
edit
)