bacon_donut

Goal Board For Crustymustard

Oct 10th, 2013
757
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. -- taked from code on this forum post: http://minecraftcomputercraft.wikia.com/wiki/LUA_Vertical_Scroller
  2.  
  3. tSides = {"left","right","bottom","top","front","back"}
  4.  
  5. for i = 1, #tSides do
  6.   monitor = peripheral.wrap(tSides[i])
  7.   if monitor then
  8.         side = tSides[i]
  9.         break
  10.   end
  11. end
  12.  
  13. term.redirect(peripheral.wrap(side))
  14. monitor.setTextScale(2)
  15. term.clear()
  16. term.setCursorPos(1,1)
  17. local data = {}
  18. local breakOut = false
  19. logo = [[
  20.                                              
  21. Crusty's Goal Board!
  22. ====================                                            
  23. ]]
  24.  
  25. function clearscreen()
  26.    local _,row=term.getCursorPos()
  27.    local _,height=term.getSize()
  28.    width, height = term.getSize()
  29.    term.setCursorPos(1,1)
  30.    dl = ""
  31.    sl = ""
  32.    for g=1,width do
  33.        dl =dl.."_"
  34.        sl = sl.." "
  35.    end
  36.    for y=1,height do
  37.        term.setCursorPos(1,y)
  38.        print(dl)
  39.        sleep(0.01)
  40.    end
  41.    
  42.    for y=1,height do
  43.        term.setCursorPos(1,y)
  44.        print(sl)
  45.        sleep(0.01)
  46.    end
  47.    term.clear()
  48. end
  49.  
  50. function printTo()
  51.    local _,row=term.getCursorPos()
  52.    local _,height=term.getSize()
  53.    term.setCursorPos(1,1)
  54.    print(logo)
  55.    term.setCursorPos(1,5)
  56.    row = 8
  57.    for i=1,#data do
  58.        print(data[i])
  59.        sleep(1)
  60.        row=row+1
  61.        if row>height then
  62.            row=height
  63.            term.scroll(1)
  64.        end
  65.  end
  66. end
  67.  
  68. local function readLines(sPath)
  69.    local file = fs.open(sPath, "r")
  70.    local line = file.readLine()
  71.    local lineNum = 0
  72.    
  73.    while line do
  74.        table.insert(data, line)        
  75.        line = file.readLine()
  76.        lineNum = lineNum + 1        
  77.    end
  78.    file.close()
  79.    sleep(1)
  80. end
  81.  
  82. function newLine()
  83.  local _,cY= term.getCursorPos()
  84.  term.setCursorPos(1,cY+1)
  85. end
  86.  
  87. function program()
  88.  while true do
  89.    clearscreen()
  90.    printTo()
  91.    sleep(0.5)
  92.  end
  93. end
  94.  
  95. function exitProgram()
  96.    repeat
  97.        local ev, key = os.pullEvent('key')
  98.    until key == 207
  99. end
  100. readLines("text.txt")
  101. parallel.waitForAny(program, exitProgram)
  102. term.restore()
Advertisement
Add Comment
Please, Sign In to add comment