Advertisement
Guest User

display

a guest
Aug 22nd, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. mon = peripheral.wrap("left")
  2. mon.setTextScale(5)
  3. mon.clear()
  4. pos = mon.getSize()
  5.  
  6. term.setTextColor(colors.red)    -- Red
  7. print("Text to display:")
  8. term.setTextColor(colors.white)  -- White
  9. text = read()
  10.  
  11. repeat
  12.   term.setTextColor(colors.red)    -- Red
  13.   print("Delay (leave blank for default):")
  14.   term.setTextColor(colors.white)  -- White
  15.   delay = read()
  16.    
  17.   if delay == "" then
  18.     delay = 0.2
  19.     valid = true
  20.   elseif tonumber(delay) < 0 then
  21.     term.setTextColor(colors.orange)-- Orange
  22.     print("Delay must be a positive number")
  23.     valid = false
  24.   elseif tonumber(delay) >= 0 then
  25.     delay = tonumber(delay)
  26.     valid = true
  27.   end
  28. until valid
  29.  
  30. term.setTextColor(colors.green)
  31. print("Now displaying: " .. '"' .. text .. '"')
  32.  
  33. while true do
  34.    pos2 = pos + text:len()
  35.    mon.setCursorPos(pos, 1)
  36.    mon.write(text)
  37.    
  38.    mon.setCursorPos(pos2, 1)
  39.    mon.write(" ")
  40.    sleep(delay)
  41.    
  42.    if pos == 0 - text:len() then
  43.      pos = mon.getSize()
  44.    else
  45.      pos = pos - 1
  46.    end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement