mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-03-04 10:38:12 +00:00
Fix line split
Also fixes a typo.
This commit is contained in:
parent
11060596b1
commit
ee20d7bed2
@ -20,17 +20,10 @@ end
|
||||
|
||||
function parseImage( sRawData )
|
||||
if type( sRawData ) ~= "string" then
|
||||
error ( "bad argument #1 (expected string, got " .. type( sRawData ) .. ")" )
|
||||
end
|
||||
local function split( str, delim ) -- modified split function from https://codea.io/talk/discussion/2118/split-a-string-by-return-newline
|
||||
if string.find( str, delim ) == nil then return { str } end
|
||||
local result, pat, lastpos = {}, "(.-)" .. delim .. "()", nil
|
||||
for part, pos in string.gfind( str, pat ) do table.insert( result, part ); lastpos = pos; end
|
||||
table.insert( result, string.sub( str, lastpos ) )
|
||||
return result
|
||||
error( "bad argument #1 (expected string, got " .. type( sRawData ) .. ")" )
|
||||
end
|
||||
local tImage = {}
|
||||
for _, sLine in pairs( split( sPath, "\n" ) ) do -- read each line like original file handling did
|
||||
for sLine in ( sRawData .. "\n" ):gmatch( "(.-)\n" ) do -- read each line like original file handling did
|
||||
tImage = parseLine( tImage, sLine )
|
||||
end
|
||||
return tImage
|
||||
|
Loading…
x
Reference in New Issue
Block a user