-Chicken-

display.lua

Feb 20th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. --[[
  2.  
  3. TO EDIT THE MESSAGE, YOU WANT TO EDIT
  4. THE "message.txt" FILE!
  5.  
  6. ]]--
  7.  
  8. --settings
  9. local filename = "message.txt"
  10. local monitor_side = "back"
  11.  
  12.  
  13. function display()
  14. mon = peripheral.wrap(monitor_side)
  15.  
  16. file = fs.open(filename, "r")
  17. s = file:readAll()
  18. file.close()
  19.  
  20. local t = {}
  21. local i = 0
  22. table.insert(t, 0)
  23. while true do
  24. i = string.find(s, "\n", i+1)
  25. if i == nil then break end
  26. table.insert(t, i)
  27. end
  28. mon.clear()
  29. local h=0
  30. local x, _ = mon.getSize()
  31. for i = 1, (#t-1) do
  32. h=h+1
  33. mon.setCursorPos(1,h)
  34. local st = string.sub(s, t[i]+1, t[i+1])
  35. if(#st > x)then
  36. fst = string.sub(st, 1, x-1)
  37. sst = string.sub(st, x, string.len(st))
  38. mon.write(fst .. "-")
  39. h = h +1
  40. mon.setCursorPos(1,h)
  41. mon.write(sst)
  42. else
  43. mon.write(st)
  44. end
  45. end
  46.  
  47. end
  48.  
  49. while(true)do
  50. stat, err = pcall(display)
  51. --if(stat == true)then
  52. --break
  53. --end
  54. print(err)
  55.  
  56. sleep(5)
  57. end
Advertisement
Add Comment
Please, Sign In to add comment