请输入您要查询的百科知识:

 

词条 Module:Sandbox/Sathuheb
释义 -- 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 .. ".
"

-- 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

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/11 6:46:06