carrots084

Untitled

Jul 28th, 2014
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. function centerText(text) --creates a function called centerText()
  2. mon = peripheral.wrap("left")
  3. mon.setTextColour(colours.red)
  4. mon.setBackgroundColour(colors.black)
  5.  
  6. local x,y =mon.getSize() --gets the size of the screen.
  7. local x2,y2 = mon.getCursorPos() --gets the current position of the cursor.
  8. mon.setCursorPos(math.ceil((x/2) - (text:len() / 2)), math.ceil(y/2)) --sets the cursor to halfway on each axis.
  9. mon.write(text) --writes the text
  10. end --ends the function
  11. while true do --infinite loop
  12. centerText("Missile Launched") --calls the function
  13. sleep(1) --sleeps for one second
  14. mon.clear() --clears the monitor screen
  15. sleep(1) --sleeps for a second
  16. end --ends the while loop
Advertisement
Add Comment
Please, Sign In to add comment