Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(pString, pPattern)
- local Table = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pPattern
- local last_end = 1
- local s, e, cap = pString:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(Table,cap)
- end
- last_end = e+1
- s, e, cap = pString:find(fpat, last_end)
- end
- if last_end <= #pString then
- cap = pString:sub(last_end)
- table.insert(Table, cap)
- end
- return Table
- end
- function love.load()
- local file = io.open("test.txt", "r");
- lines = {}
- for line in file:lines() do
- table.insert (lines, line);
- end
- file:close()
- colors = {}
- for i=1, #lines do
- lines[i] = split(lines[i], " ")
- table.remove(lines[i], 1)
- for n=1, #lines[i] do
- colors[#colors + 1] = lines[i][n]
- end
- end
- print(#colors)
- end
- function love.draw()
- love.graphics.print(#colors, 10, 10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement