Module:LuaCall: Difference between revisions
From Test Wiki
Content deleted Content added
p.get() special example |
You still haven't explained how p.import is within the scope of this module |
||
| Line 53: | Line 53: | ||
end |
end |
||
return args |
return args |
||
end |
|||
-- This function is modified from https://en.wikipedia.org/wiki/Module:Ustring?oldid=885619921 |
|||
-- All frame's arguments are coerced as number type if possible. If you wish for something to remain a string, you can simply escape it by insert \ at the beginning of the string. |
|||
function p.import(o) |
|||
local p = {} |
|||
for k, v in pairs(o) do if type(v)~='function' then p[k]=v else |
|||
p[k] = function(frame) |
|||
--local args = {} |
|||
--for _, v in ipairs(frame.args) do |
|||
-- --table.insert(args, tonumber(v) or v:gsub("^\\", "", 1)) |
|||
-- table.insert(args, tonumberOrString(v)) |
|||
--end |
|||
--return (v(unpack(args))) |
|||
return (v(unpack( |
|||
tonumberOrStringOnPairs(ipairs(frame.args)) |
|||
))) |
|||
end |
|||
end |
|||
end |
|||
return p |
|||
end |
end |
||