--Load and save plaintext line mesh format for DEFCON coastlines etc. local t = {} local lfs = love.filesystem local lg = love.graphics function t.load( filename ) local polys = { visible = true } local poly = {} local n = 1 local k = 1 for line in assert( lfs.lines( filename ) ) do if line:find "b" then k = 1 if #poly > 2 then n = n + 1 end poly = {} polys[n] = poly else local _, _, x, y = line:find( "(%g+)%s+(%g+)" ) x, y = tonumber( x ), tonumber( y ) if x and y then poly[k], poly[ k + 1 ] = x, y k = k + 2 else print( "LINES: malformed line:", filename, line ) end end end if not polys[n] or (#(polys[n]) < 3) then polys[n] = nil n = n - 1 end print( "LOADED", filename, n ) return setmetatable( polys, {__index = t } ) end function t.save( lines, filename ) end function t.newPolygon( x, y ) end function t.addToCurrentPolygon( x, y ) end function t.deletePolygon( poly ) end function t.drawPolygonEditHandles( poly ) end function t.draw( lines ) if not lines.visible then return end for _, poly in ipairs( lines ) do lg.line( poly ) end end return t