Advertisement
BigSHinyToys

animation experement

Jun 12th, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.62 KB | None | 0 0
  1. --[[
  2.     local basic load and play
  3. ]]--
  4. --[[
  5. local function loadImage(sPath) -- text image no color
  6.     local file = fs.open(sPath,"r")
  7.    
  8.     local tOut = {}
  9.    
  10.     if file then
  11.         local sLine = file.readLine()
  12.         while sLine do 
  13.             tOut[#tOut + 1] = sLine
  14.             sLine = file.readLine()
  15.         end
  16.         file.close()
  17.     else
  18.         error("unable to open file")
  19.     end
  20.    
  21.     return tOut
  22. end
  23. ]]--
  24. local function displayImage(tImg)
  25.     local termX,termY = term.getSize()
  26.     for y = 1,termY do
  27.         term.setCursorPos(1,y)
  28.         term.write(tImg[y] or "")
  29.     end
  30. end
  31.  
  32. --local tArgs = {...}
  33.  
  34. local tAnimation = {
  35.     normal = {
  36. [[     O O
  37.     | _ |
  38.      [ ]
  39.      ^ ^]],},
  40.     blink = {
  41. [[     O O
  42.     | _ |
  43.      [ ]
  44.      ^ ^]],
  45. [[     - -
  46.     / _ \
  47.      [ ]
  48.      ^ ^]],},
  49.     shuffel = {
  50. [[     O O
  51.     | _ |
  52.      [ ^
  53.      ^  ]],
  54. [[     O O
  55.     | _ |
  56.      ^ ]
  57.        ^]],
  58. [[
  59.      O O
  60.     | _ |
  61.      ^ ^]],},
  62.     snore = {
  63. [[     z
  64.      O O
  65.     | _ |
  66.      ^ ^]],
  67. [[      z
  68.      - -
  69.     | _ |
  70.      ^ ^]],
  71. [[       z
  72.      - ~
  73.     | _ |
  74.      ^ ^]],
  75. [[     z  Z
  76.      ~ -
  77.     | _ |
  78.      ^ ^]],
  79. [[      z
  80.      - -
  81.     | _ |
  82.      ^ ^]],
  83. [[      *
  84.      - o
  85.     | _ |
  86.      ^ ^]],
  87. [[
  88.      O O
  89.     | _ |
  90.      ^ ^]],},
  91.     smile = {
  92. [[     O O
  93.     | u |
  94.      [ ]
  95.      ^ ^]],
  96. [[     O O
  97.     | U |
  98.      [ ]
  99.      ^ ^]],
  100. [[     O O
  101.     | u |
  102.      [ ]
  103.      ^ ^]],},
  104.     side = {
  105. [[     O O
  106.     | _ |
  107.      [ ]
  108.      ^ ^]],
  109. [[      O O
  110.      | _ |
  111.      / /
  112.      ^ ^]],
  113. [[     O O
  114.     | _ |
  115.      [ ]
  116.      ^ ^]],
  117. [[    O O
  118.    | _ |
  119.      \ \
  120.      ^ ^]],
  121. [[     O O
  122.     | _ |
  123.      [ ]
  124.      ^ ^]],},
  125.     flap = {
  126. [[     O O
  127.     | _ |
  128.      [ ]
  129.      ^ ^]],
  130. [[     O O
  131.     / _ \
  132.      ^ ^
  133.  ]],
  134. [[   _ O O _
  135.       _
  136.      ^ ^
  137.  ]],
  138. [[     O O
  139.     / _ \
  140.      ^ ^
  141.  ]],
  142. [[   _ O O _
  143.       _
  144.      ^ ^
  145.  ]],
  146. [[     O O
  147.     / _ \
  148.      ^ ^
  149.  ]],},
  150. }
  151.  
  152. local tTypes = {}
  153.  
  154. for key,value in pairs(tAnimation) do
  155.     tTypes[#tTypes + 1] = key
  156. end
  157.  
  158. while true do
  159.     local nType = math.random(#tTypes)
  160.     term.clear()
  161.     term.setCursorPos(1,1)
  162.     print("normal")
  163.     write(tAnimation.normal[1])
  164.     sleep(1)
  165.     for i = 1,#tAnimation[tTypes[nType]] do
  166.         term.clear()
  167.         term.setCursorPos(1,1)
  168.         print(tTypes[nType])
  169.         write(tAnimation[tTypes[nType]][i])
  170.         sleep(1)
  171.     end
  172. end
  173.  
  174. --[[
  175. if tArgs[1] then
  176.     if fs.isDir(tArgs[1]) then
  177.         local list = fs.list(tArgs[1])
  178.         table.sort(list)
  179.         for i = 1,#list do
  180.             tPics[#tPics + 1] = loadImage(tArgs[1].."/"..list[i])
  181.         end
  182.         while true do
  183.             for i = 1,#tPics do
  184.                 displayImage(tPics[i])
  185.                 sleep(1)
  186.             end
  187.         end
  188.     else
  189.         error("requires directory")
  190.     end
  191. else
  192.     error("usage <folder path>")
  193. end
  194. ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement