Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Ajuanca/
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!
-- Ajuanca Google Code-in 2019, Introduction to Lua in Wikipedia. local p = {} function p.hello( frame ) return "Hello, world!" end p.Hi = function(frame) strName = frame.args.name or "Jimmy" end function p.converttemp(frame) cels = tonumber(frame.args.celsius) or 0 fahr = (((cels * 9) / 5) + 32) kelvin = cels + 273.15 str = cels .. " degrees Celsius is " .. fahr .. " degrees Fahrenheit." str = str .. " That's the same as say " .. kelvin .. " Kelvin." if cels > 9 then str = str .. " It is warm." elseif cels < 9 then str = str .. " It is cold." else str = str .. " It isn't neither warm nor cold." end return str end -- Task 4 -- Timestable function function p.timestable(frame) local random = math.random(-12, 12) local numb = tonumber( frame.args.numb ) or random local out = "<h4> The " .. numb .. " times table. </h4>" out = out .. "When no number is given or no parameter is sended, the default value is used. Instead of 2, the default number is generated randomly between -12 and 12, and in this case is " .. random .. ".<br>" for i = 1, 12 do out = out .. i .. " times " .. numb .. " equals " .. i * numb .. "<br>" end return out end -- People function function p.people(frame) local friends = {"Agnetha", "Betty", "Carlos", "Davinder", "Eloise", "Martin", "Doug", "Diego"} local msg = "" for i = 1, #friends do msg = msg .. "Hello " .. friends[i] .. "<br>" end return msg end function p.orgnanizeLanguages() local allLanguages = mw.language.fetchLanguageNames() local organizedLanguages = {} local maximun = 0 local minimu = 0 for k, v in pairs(allLanguages) do for i = 1, table.getn(organizedLanguages)+1, 1 do if i == 1 then maximun = 0 minimun = 0 end if table.getn(organizedLanguages) == 0 then table.insert(organizedLanguages, i, k) elseif i == 1+table.getn(organizedLanguages) then for x = 0, table.getn(organizedLanguages), 1 do if x < maximun and x > minimun then table.insert(organizedLanguages, x, k) end end else if table.getn(mw.language.getFallbacksFor(k)) < table.getn(mw.language.getFallbacksFor(organizedLanguages[i])) then if maximun > table.getn(mw.language.getFallbacksFor(organizedLanguages[i])) then maximun = i end elseif table.getn(mw.language.getFallbacksFor(k)) == table.getn(mw.language.getFallbacksFor(organizedLanguages[i])) then table.insert(organizedLanguages, i+1, k) else if minimun < table.getn(mw.language.getFallbacksFor(organizedLanguages[i])) then minimun = i end end end end end local out = "" for d = 0, table.getn(organizedLanguages), 1 do out = out .. organizedLanguages[d] .. " - " .. table.getn(mw.language.getFallbacksFor(organizedLanguages[d])) .. "<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/Ajuanca//doc
(
edit
)