Module:Sandbox/Yupik

--comment --task2

p={} --this is an empty table; all of our modules will probably start with this --in a sense, p is table that holds all the names of the functions --p is the conventional variable for this

function p.Namma(frame) --function is a datatype in Lua; when we're calling things from outside the module, use frame return "Dearvva máilbmi!" end --end marks the end of a block in Lua

p.Hi = function(frame) -- this is the same as function p.Hi(frame). Some people prefer one way over the other strName = frame.args.name or "Jimbo" --str* is just a hint that a string is expected. args is the list of parameters you passed to that function --boolean ops => lowercase --if first part is not true, read second part return "Dearvva Luas mu ustibiidda! " .. strName .. ". " --don't forget to use the same name for the var here; double dot is the concat operator end

--task3 function p.temp(frame) cel = tonumber(frame.args.celsius) or 0 --this is a string; if tonumber can't convert str into number, it returns nil, not the orig value, so it will fail. fah = cel*9/5+32 --here it's not --this will autocache it into a floating point if cel > 10 then --this is a test msg = " ja dat lea liekkas!" --note: space else msg = " ja dat ii gal leat liekkas!" end --this is the end of the test return "Temperatuvra fahrenheitis lea " .. fah .. msg .. " " end

--task 4 p.times = function(frame) local num = tonumber(frame.args.num) or 2 local out = num .. " times table " for i = 1, 10 do       out = out .. num .. " x " .. i .. ": " .. i * num .. " "   end return out end

return p --table is Lua's only complex data type; everything is made out of them in Lua --indices in Lua can be any datatype