Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/hakanist
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!
-- 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 .. ".<br>" 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<br>" for i = 1, 10 do out = out .. i* num .. "<br>" end return out end 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/hakanist/doc
(
edit
)