Advertisement
craftyoyo

Untitled

Apr 29th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.37 KB | None | 0 0
  1.    
  2.  
  3.     mon = peripheral.wrap("left")
  4.     function lineBreak()
  5.         x, y = mon.getCursorPos()
  6.         if y ~= 1 then
  7.                 y = y + 1
  8.         end
  9.         mon.setCursorPos(1, y)
  10.         width, height = mon.getSize()
  11.         mon.write("+" .. string.rep("-", width - 2) .. "+")
  12.     end
  13.     function printString(sString)
  14.         x, y = mon.getCursorPos()
  15.         y = y + 1
  16.         mon.setCursorPos(1, y)
  17.         mon.write(sString)
  18.     end
  19.     function printStringCentre(sString)
  20.         x, y = mon.getCursorPos()
  21.         y = y + 1
  22.         mon.setCursorPos(1, y)
  23.         width, height = mon.getSize()
  24.         nStringCentre = math.floor(string.len(sString) / 2)
  25.         nMonitorCentre = math.floor(width / 2)
  26.         x = math.floor(nMonitorCentre - nStringCentre)
  27.         mon.setCursorPos(x, y)
  28.         mon.write(sString)
  29.     end
  30.     function printStringRight(sString)
  31.     width, height = mon.getSize()
  32.     x, y = mon.getCursorPos()
  33.     y = y + 1
  34.     x = math.ceil(width - string.len(sString))
  35.     mon.setCursorPos(x, y)
  36.     mon.write(sString)
  37.     end
  38.     function scrollText(tStrings, nRate)
  39.     nRate = nRate or 5
  40.     if nRate < 0 then
  41.       error("rate must be positive")
  42.     end
  43.     local nSleep = 1 / nRate
  44.      
  45.     width, height = mon.getSize()
  46.     x, y = mon.getCursorPos()
  47.         sText = ""
  48.         for n = 1, #tStrings do
  49.                 sText = sText .. tostring(tStrings[n])
  50.       sText = sText .. " | "
  51.         end
  52.         sString = "| "
  53.         if width / string.len(sText) < 1 then
  54.                 nStringRepeat = 3
  55.         else
  56.                 nStringRepeat = math.ceil(width / string.len(sText) * 3)
  57.         end
  58.     for n = 1, nStringRepeat do
  59.       sString = sString .. sText
  60.     end
  61.     while true do
  62.       for n = 1, string.len(sText) do
  63.        sDisplay = string.sub(sString, n, n + width - 1)
  64.        mon.clearLine()
  65.        mon.setCursorPos(1, y)
  66.        mon.write(sDisplay)
  67.        sleep(nSleep)
  68.       end
  69.     end
  70.     end
  71.     mon.clear()
  72.     mon.setCursorPos(1, 1)
  73.     lineBreak()
  74.     printStringCentre("|News Board|")
  75.     lineBreak()
  76.     printString("")
  77.     lineBreak()
  78.     tScrollText = {}
  79.     tScrollText[1] = "Type /warp underspawn to get down from here."
  80.     tScrollText[2] = "Type /warp city to go to the city."
  81.     x, y = mon.getCursorPos()
  82.     y = y - 1
  83.     mon.setCursorPos(1, y)
  84.     scrollText(tScrollText)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement