Nezn

Slowly Writing [CC]

Jul 10th, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. args = {...}
  2. if args[1] == nil then
  3.     print("Need a phrase!")
  4.     error(r)
  5. end
  6. str = args[1].."            "
  7.  
  8. function findMonitor()
  9.     local e = peripheral.getNames()
  10.     for i=1,#e do
  11.         if peripheral.getType(e[i]) == "monitor" then
  12.             local m = peripheral.wrap(e[i])
  13.             return m
  14.         end
  15.     end
  16.     print("Need monitor!")
  17.     error(r)
  18. end
  19.  
  20. function wrt(s)
  21.     term.setCursorPos(1,1)
  22.     term.setBackgroundColor(colors.white)
  23.     term.setTextColor(colors.black)
  24.     term.clearLine()
  25.     term.write(s)
  26.     term.setCursorPos(1,2)
  27.     term.setBackgroundColor(colors.gray)
  28.     term.setTextColor(colors.white)
  29.     term.clearLine()
  30.     term.write(s)
  31. end
  32.  
  33. function main()
  34.     term.clear()
  35.     term.setCursorPos(1,1)
  36.     --print("Touch the screen to select application")
  37.     local monitor = findMonitor()
  38.     monitor.setTextScale(5)
  39.     term.redirect(monitor)
  40.     term.setCursorPos(1,2)
  41.     term.setBackgroundColor(colors.white)
  42.     term.setTextColor(colors.black)
  43.     --local timer = 0
  44.     while true do
  45.         --timer = os.startTimer(1/2)
  46.         term.clear()
  47.         wrt(str)
  48.         --local event, arg1, arg2, arg3 = os.pullEvent()
  49.         --[[if event == "monitor_touch" then
  50.             break
  51.         elseif event == "timer" and arg1 == timer then
  52.             str = string.sub(str,2,string.len(str))..string.sub(str,1,1)
  53.         end]]--
  54.         str = string.sub(str,2,string.len(str))..string.sub(str,1,1)
  55.         sleep(0.5)
  56.     end
  57.     --[[term.setBackgroundColor(colors.black)
  58.     term.clear()
  59.     term.redirect(term.native())
  60.     shell.run("reboot")]]--
  61. end
  62.  
  63. main() --Start application
Advertisement
Add Comment
Please, Sign In to add comment