Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you Parse this String in Lua "1 2 3 4"?
    primarykey
    data
    text
    <p>I am brand new to Lua from a pure VB.Net background. I have a large file of maplines that I need to iterate through. The data is in the form of:</p> <p>;XX.XXX YY.YYY Name ; [Airways] 58.50 -12.44 58.21 -13.73</p> <p>58.21 -13.73 57.89 -15.02</p> <p>57.89 -15.02 57.54 -16.30</p> <p>57.54 -16.30 57.17 -17.58</p> <p>57.17 -17.58 56.76 -18.84</p> <p>56.76 -18.84 56.33 -20.10</p> <p>56.33 -20.10 55.87 -21.35</p> <p>54.33 -25.02 53.77 -26.22</p> <p>I have tried this but keep getting an error.</p> <pre><code>local mapLines = {} local filePath = system.pathForFile( "data.ini", system.DocumentsDirectory ) local file = io.open( filePath, "r" ) if file then local contents = file:read( "*a" ) --print( "Contents of " .. filePath ) --print( contents ) io.close( file ) local t = display.newText( "Contents of ", 5, 80, nil, 16 ); t:setTextColor( 255, 255, 136, 255 ); local t = display.newText( filePath, 5, 100, nil, 10 ); t:setTextColor( 255, 255, 136, 255 ); local ylast = 130 for line in io.lines(filePath) do local t = display.newText( line, 15, ylast, nil, 14 ); t:setTextColor( 255, 255, 255 ); ylast = ylast + 20 n = tonumber(line); if n == nil then local f = {} s = "1 2 3 4" for k, v in string.gmatch(s, "(%w+) (%w+)") do f[k] = v end local myLine = newLine(tonumber(f[1]), tonumber(f[2]), tonumber(f[3]), tonumber(f[4])) table.insert( mapLines, myLine ) end end end -- Example of shape drawing func local function newLine(x,y,x1,y1) -- need initial segment to start local Line = display.newLine( x, y, x1, y1 ) Line:setColor( 30, 155, 30, 100 ) Line.width = 3 return Line end Runtime:addEventListener( "enterFrame", mapLines ) </code></pre> <p>Any help would be greatly appreciated!</p> <p>Dave</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload