Advertisement
billysback

ccani

Oct 6th, 2012
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1.  
  2. local function getLines(dir)
  3.     local data = {}
  4.     local cur = 1
  5.     local file = fs.open(dir, "r")
  6.     local line = file.readLine()
  7.     while line ~= nil do
  8.         data[cur] = line
  9.         cur = cur + 1
  10.         line = file.readLine()
  11.         sleep(0)
  12.     end
  13.     file.close()
  14.     return data
  15. end
  16.  
  17. local function getFrames(dir)
  18.     local dataf = {}
  19.     local cur = 1
  20.    
  21.     local curdir = dir.."frame"..(cur-1)..".frm"
  22.     while fs.exists(curdir) do
  23.         dataf[cur] = getLines(curdir)
  24.         cur = cur + 1
  25.         curdir = dir.."frame"..(cur-1)..".frm"
  26.     end
  27.     return dataf
  28. end
  29.  
  30. local function getTableSize(table)
  31.     local cur = 0
  32.     for i,v in ipairs(table) do
  33.         cur = i
  34.     end
  35.     return cur
  36. end
  37.  
  38. function setUp()
  39.     fs.makeDir("CCAni")
  40. end
  41.  
  42.  
  43.  
  44. local looper = true
  45.  
  46. function stopLoop()
  47.     looper = false
  48. end
  49.  
  50. function runFrame(frame)
  51.     for i,v in ipairs(frame) do
  52.         local line = v
  53.        
  54.         print(line)
  55.     end
  56. end
  57.  
  58. function runAnimation(name, pause, loop)
  59.     local frames = getFrames("CCAni/"..name.."/")
  60.     local x = 1
  61.     local sz = getTableSize(frames)
  62.     local j = 1
  63.     for j=1,loop,1 do
  64.         for x=1,sz,1 do
  65.             term.clear()
  66.             term.setCursorPos(1,1)
  67.             local frame = frames[x]
  68.             runFrame(frame)
  69.             sleep(pause)
  70.         end
  71.     end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement