Module:MapTiles

local p = {} function p.mapTiles( f ) local args = f:getParent.args local cellSize = tonumber(args[2]) if cellSize == nil then cellSize = 10 end

-- the map has 6 x 6 tiles labeled 0-5, X is horizontally, Y is vertically, origin is south-west local tiles = {} for x=0,5 do   tiles[x]={} for y=0,5 do     tiles[x][y]=false end end

for rec in string.gmatch(args[1], "X%dY%d%-?X?%d?Y?%d?") do   local x1, y1, x2, y2 = string.match(rec,"X(%d)Y(%d)%-?X?(%d?)Y?(%d?)") if x1 ~= nil then x1 = clamp(x1, 0, 5) x2 = clamp(x2, 0, 5) y1 = clamp(y1, 0, 5) y2 = clamp(y2, 0, 5) -- if the end is ommitted, use the start if x2 == nil then x2 = x1 end if y2 == nil then y2 = y1 end

for x=x1,x2 do       for y=y1,y2 do          tiles[x][y]=true end end end end

local htmlEl = ' '

return htmlEl

end

function clamp(n,min,max) n = tonumber(n) if n ~= nil then if nmax then n=max end return n end return nil end

return p