Advertisement
gpgautier

xtreamcraft - news

Dec 22nd, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. local title = "XtreamTech News and Messages"
  2.  
  3. local news = {
  4.   "Builds that really lag the server have the risk of being destroyed by staff"
  5.   , "An excessive amount of power flowers is frowned upon, because of server lag"
  6. }
  7.  
  8. function main()
  9.   term.clear()
  10.  
  11.   local monitor, _, side, width, height, i, padding, item, firstLine, x, y
  12.  
  13.   firstLine = 2
  14.  
  15.   for _, side in pairs(rs.getSides()) do
  16.     if peripheral.isPresent(side) then
  17.       if peripheral.getType(side) == "monitor" then
  18.         monitor = peripheral.wrap(side)
  19.       end
  20.     end
  21.   end
  22.  
  23.   if monitor == nil then
  24.     print("Please attach a monitor to any side")
  25.     return
  26.   end
  27.  
  28.   width, height = monitor.getSize()
  29.  
  30.   monitor.clear()
  31.   monitor.setCursorPos(1, firstLine)
  32.  
  33.   for i = 1, width do
  34.     monitor.write("=")
  35.   end
  36.  
  37.   padding = (width / 2) - (#title / 2)
  38.  
  39.   monitor.setCursorPos(1, firstLine + 2)  
  40.   for i = 1, padding do
  41.     monitor.write(" ")
  42.   end
  43.  
  44.   monitor.write(title)
  45.  
  46.   monitor.setCursorPos(1, firstLine + 4)
  47.   for i = 1, width do
  48.     monitor.write("=")
  49.   end
  50.  
  51.   for _, item in pairs(news) do
  52.     monitor.setCursorPos(1, firstLine + 6 + _)
  53.     monitor.write("")    
  54.  
  55.     x, y = monitor.getCursorPos()
  56.     monitor.setCursorPos(1, y + 2)    
  57.  
  58.     if _ < 10 then
  59.       monitor.write(" ")
  60.     end
  61.  
  62.     monitor.write("   " .. _ .. ". " .. item)
  63.   end
  64. end
  65.  
  66. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement