Alyssa

Rainbow print API

Aug 23rd, 2013 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. --By Allymonies
  2. --Download at lightning.com (Firewolf)
  3. --Alternate download (Preferably, use the above site though) at api.com(Also a firewolf site)
  4. function print(text)
  5.  color = 0
  6.  for i = 1, #text do
  7.   c = text:sub(i,i)
  8.   if color ~= 6 then
  9.    color = color +1
  10.   else
  11.    color =1
  12.   end
  13.   if color == 1 then
  14.    term.setTextColor(colors.red)
  15.   elseif color == 2 then
  16.    term.setTextColor(colors.orange)
  17.   elseif color == 3 then
  18.    term.setTextColor(colors.yellow)
  19.   elseif color == 4 then
  20.    term.setTextColor(colors.lime)
  21.   elseif color == 5 then
  22.    term.setTextColor(colors.blue)
  23.   else
  24.    term.setTextColor(colors.purple)
  25.   end
  26.   write(c)
  27.  end
  28.  term.setTextColor(colors.white)
  29.  x,y = term.getCursorPos()
  30.  term.setCursorPos(1,y +1)
  31.  c = nil
  32.  color = nil
  33.  text = nil
  34.  return true
  35. end
  36.  
  37. function slowprint(text, speed)
  38.  color = 0
  39.  if speed then
  40.   timer = speed /20
  41.  else
  42.   timer = 0.05
  43.  end
  44.  for i = 1, #text do
  45.   sleep(timer)
  46.   c = text:sub(i,i)
  47.   if color ~= 6 then
  48.    color = color +1
  49.   else
  50.    color =1
  51.   end
  52.   if color == 1 then
  53.    term.setTextColor(colors.red)
  54.   elseif color == 2 then
  55.    term.setTextColor(colors.orange)
  56.   elseif color == 3 then
  57.    term.setTextColor(colors.yellow)
  58.   elseif color == 4 then
  59.    term.setTextColor(colors.lime)
  60.   elseif color == 5 then
  61.    term.setTextColor(colors.blue)
  62.   else
  63.    term.setTextColor(colors.purple)
  64.   end
  65.   write(c)
  66.  end
  67.  term.setTextColor(colors.white)
  68.  x,y = term.getCursorPos()
  69.  term.setCursorPos(1,y +1)
  70.  c = nil
  71.  color = nil
  72.  text = nil
  73.  speed = nil
  74.  timer = nil
  75.  return true
  76. end
  77.  
  78. function rwrite(text)
  79.  color = 0
  80.  for i = 1, #text do
  81.   c = text:sub(i,i)
  82.   if color ~= 6 then
  83.    color = color +1
  84.   else
  85.    color =1
  86.   end
  87.   if color == 1 then
  88.    term.setTextColor(colors.red)
  89.   elseif color == 2 then
  90.    term.setTextColor(colors.orange)
  91.   elseif color == 3 then
  92.    term.setTextColor(colors.yellow)
  93.   elseif color == 4 then
  94.    term.setTextColor(colors.lime)
  95.   elseif color == 5 then
  96.    term.setTextColor(colors.blue)
  97.   else
  98.    term.setTextColor(colors.purple)
  99.   end
  100.   write(c)
  101.  end
  102.  term.setTextColor(colors.white)
  103.  x,y = term.getCursorPos()
  104.  term.setCursorPos(x+1,y)
  105.  c = nil
  106.  color = nil
  107.  text = nil
  108.  return true
  109. end
Add Comment
Please, Sign In to add comment