Difference between revisions of "Module:Test"
Jump to navigation
Jump to search
Line 62: | Line 62: | ||
end | end | ||
for name = cf.args[1], cf.args[2] | for name = cf.args[1], cf.args[2] do | ||
table.insert(aList, name) | table.insert(aList, name) | ||
end | end | ||
return "Total element count: " .. | return "Total element count: " .. tostring(aList) .. " and " .. count2 .. " elements." | ||
end | end | ||
return p | return p |
Revision as of 15:30, 9 August 2021
Documentation for this module may be created at Module:Test/doc
p = {}
function p.hello_world(a)
cf = mw.getCurrentFrame()
return "Hello, world! from " .. mw.allToString(cf.args[3]) .. "-" .. mw.allToString(cf.args[1]) .."-" ..mw.allToString(cf.args[2])
end
function p.greek_letter()
cf = mw.getCurrentFrame()
-- aString = "<math>\\" .. mw.allToString(cf.args[1]) .. "</math>"
aString = "<math>\\pi</math>"
return aString
end
function p.rawstring()
cf = mw.getCurrentFrame()
return mw.allToString(cf.args[1])
end
function p.selector()
cf = mw.getCurrentFrame()
arg1 = cf.args[1]
if arg1 == "1" then
return mw.allToString(cf.args[2])
elseif arg1 == "2" then
return mw.allToString(cf.args[3])
else
return "Error"
end
end
function p.multiArgument()
cf = mw.getCurrentFrame()
arg1 = cf.args[1]
arg2 = cf.args[2]
arg3 = cf.args[3]
return arg1 .. " ," .. arg2 .. " ," .. arg3
end
function p.arithmetic(cf)
arg1 = cf.args[1]
arg2 = cf.args[2]
arg3 = cf.args[3]
num = 0 + arg1 + arg2 + arg3
return num
end
function p.trig(cf)
return math.cos(cf.args[1])
end
function p.repetition(cf)
aList = {1,2,3,4,5}
aString = ""
count = cf.args[1] + 0
count2 = cf.args[2] + 0
while count > 0
do
table.insert(aList, count)
count = count -1
end
for name = cf.args[1], cf.args[2] do
table.insert(aList, name)
end
return "Total element count: " .. tostring(aList) .. " and " .. count2 .. " elements."
end
return p