Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Open file
- local sDir = string.sub(sPath, 1, #sPath - #fs.getName(sPath))
- if not fs.exists(sDir) then
- fs.makeDir(sDir)
- end
- local file = fs.open( path, "w" )
- if not file then
- return false
- end
- -- Encode (and trim)
- local tLines = {}
- local nLastLine = 0
- for y=1,h-1 do
- local sLine = ""
- local nLastChar = 0
- for x=1,w-2 do
- local c = getCharOf( getCanvasPixel( x, y ) )
- sLine = sLine .. c
- if c ~= " " then
- nLastChar = x
- end
- end
- sLine = string.sub( sLine, 1, nLastChar )
- tLines[y] = sLine
- if string.len( sLine ) > 0 then
- nLastLine = y
- end
- end
- -- Save out
- for n=1,nLastLine do
- file.writeLine( tLines[ n ] )
- end
- file.close()
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement