Module:TestMod: Difference between revisions

From Hazeron Wiki
Jump to navigation Jump to search
mNo edit summary
(number seems to be 1 higher than intended)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {} --p stands for package
local p = {} --p stands for package


function p.hello( frame )
function p.countArgs( frame )
    local i = {}
     local args = frame.args
     local args = frame.args
    local i = 1
     while args[i] do i = i + 1 end
     while args[i] do i = i + 1 end
     local OutText = i .. "arguments were provided. The module will now check for the existence of arg5 and print it if set. "
     return "You entered " .. i - 1 .. " arguments."
    if(arg[5]) then OutText = OutText .. arg[5] end
    return OutText
    --return "This should have printed the first argument you entered: " .. args[1] .. "!"
end
end


return p
return p

Latest revision as of 11:00, 18 April 2024

Basic test Lua module, can be invoked with {{#invoke: TestMod|FunctionName|arg1|arg2|etc ...}}


local p = {} --p stands for package

function p.countArgs( frame )
    local args = frame.args
    local i = 1
    while args[i] do i = i + 1 end
    return "You entered " .. i - 1 .. " arguments."
end

return p