Module:Zandbak
Deze pagina dient voor tests en experimenten met Lua-modules.
Nieuwe functies toevoegen kan en mag altijd, maar laat de bestaande functies aub. intact; daar wordt mischien nog mee getest!
local p = {}
function p.y()
mw.addWarning("test: bold?")
end
function p.x(frame)
return mw.site.stats.pagesInNamespace(tonumber(frame.args[1]))
end
function p.test(frame)
local t = {}
local retval = ""
local sX = "0, 100, 200, 300" -- frame.args[1]
local sY = "0, 100, 50, 300" -- frame.args[2]
sX = string.gsub(sX, "%s", "")
sY = string.gsub(sY, "%s", "")
tX = p._split(sX, ",") -- p._split() returns een array!
tY = p._split(sY, ",")
for i = 2, #(tX), 1 do -- #(tX) geeft aantal elementen van array tX
-- {{L|x1=200|y1= 50|x2=400|y2=300}}
retval = retval .. "{{L" .. "|x1=" .. tX[i-1] .. "|y1=" .. tY[i-1] .. "|x2=" .. tX[i] .. "|y2=" .. tY[i] .. "}}\n"
end
return retval
end
function p._split (inputstr, sep)
-- NB.: -> local!? hoe? -> local function _split (inputstr, sep) !!
-- debug: =p._split("aap noot mies")
if sep == nil then sep = "%s" end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return "1: " .. t[1] .. ", 2: " .. t[2] -- 2 of meer parameters verwacht; meer mag, maar die doen niets.
end
function p.echo(frame)
return frame.args[1]
end
function p.link(frame) -- {{#Invoke:Zandbak|link|test}} werkt
return "[[" .. frame.args[1] .. "]]"
end
function p.sjab(frame) -- {{#Invoke:Zandbak|sjab|test}} werkt NIET
return "{{" .. frame.args[1] .. "}}"
end
function p.az_anchors(frame)
local temp = ""
for i = 65, 90 do
temp = temp .. "[[#" .. string.char(i) .. "|" .. string.char(i) .. "]]"
if i < 90 then temp = temp .. " · " end
end
for j = 1, 3 do
if type(frame.args[j]) == "string" then
temp = temp .. " · [[#" .. frame.args[j] .. "|" .. frame.args[j] .. "]]"
end
end
return temp
end
function p.az_links(frame)
-- ...
end
function p._err_msg(txt)
return '<span style="color: #dd3333; font-size: larger; font-weight: bold;">Error: ' .. txt .. '!</span>'
end
return p