Example
Line Iterators
Example 0103: Line Iterators
  1. -- Example: Line Iterators 
  2.  
  3. function load() 
  4.  
  5.    -- Set the font. 
  6.    love.graphics.setFont(love.default_font, 8
  7.  
  8.    -- Store the lines in this table. 
  9.    lines = {} 
  10.  
  11.    -- Open the file main.lua and loop through the first 
  12.    -- 50 lines. 
  13.    for line in love.filesystem.lines("main.lua"do 
  14.       table.insert(lines, line) 
  15.       if #lines >= 50 then break end 
  16.    end 
  17.  
  18. end 
  19.  
  20. function draw() 
  21.    -- Draw the loaded lines. 
  22.    for i = 1,#lines do 
  23.       love.graphics.draw("Line " .. i .. ": " .. lines[i], 5050+(i*10)) 
  24.    end 
  25. end 
  26.  
Copyright © 2006-2008 LÖVE Development Team.