词条 | Module:Sandbox/alex.osheter/listtest |
释义 | local p = {} function p.parseNames(frame) return frame [[local trackNames = frame.args[1] -- Comma separated names of tracks local output = "{{Track listing" counter = 1 for word in string.gmatch(trackNames, '([^, ]+)') do output = output .. " | title" .. counter .. " = " .. word counter = counter + 1 end output = output .. "}}" return output]]--
end function p.Name2(frame) -- This section is the core of the module. 'Name2' is a name of your choice. The same name needs to be referred to when the module is used. -- The next five lines are mostly for convenience only and can be used as is for your module. The output conditions start on line 20. local pf = frame:getParent().args -- This line allows template parameters to be used in this code easily. The equal sign is used to define variables. 'pf' can be replaced with a word of your choice. local f = frame.args -- This line allows parameters from {{#invoke:}} to be used easily. 'f' can be replaced with a word of your choice. local M = f[1] or pf[1] -- f[1] and pf[1], which we just defined, refer to the first parameter. This line shortens them as 'M' for convenience. You could use the original variable names. local m = f[2] or pf[2] -- Second shortened as 'm'. if m == nil then -- If the second parameter is not used. return 'Lonely' -- Outputs the string 'Lonely' if the first condition is met. else return 'Be positive!' end end |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。