Jackson_Pike

PikeLib

Aug 4th, 2017 (edited)
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. function fetchPeripheral()
  2.     local names = peripheral.getNames()
  3.     local i, name
  4.     for i, name in pairs(names) do
  5.         if peripheral.getType(name) == "monitor" then
  6.             return peripheral.wrap(name)
  7.         else
  8.             return "FAILED"
  9.         end
  10.     end
  11. end
  12.  
  13. Positions = {
  14.     "TOP_LEFT",
  15.     "TOP_RIGHT",
  16.     "BOTTOM_LEFT",
  17.     "BOTTOM_RIGHT",
  18.     "CENTER"
  19. }
  20. function writeText(xPos, yPos, bgd_color, txt_color, text, mon)
  21.     mon.setCursorPos(xPos, yPos)
  22.     mon.setBackgroundColor(bgd_color)
  23.     mon.setTextColor(txt_color)
  24.     mon.write(text)
  25. end
  26.  
  27.  
  28. function easyWrite(position, bgd_color, txt_color, text, mon)
  29.     xPos, yPos = mon.getSize()
  30.     textLen = string.len(text)
  31.     halfText = textLen / 2
  32.     if position == Positions[5] then
  33.         centerX = xPos/2 - halfText
  34.         centerY = yPos/2
  35.         writeText(centerX, centerY, bgd_color, txt_color, text, mon)
  36.     end
  37. end
  38.  
  39. function drawBars(color, yPos, mon)
  40.     monX, monY = mon.getSize()
  41.     mon.setBackgroundColor(color)
  42.     mon.setCursorPos(1, yPos)
  43.     mon.write(string.rep(" ", monX))
  44.     mon.setBackgroundColor(colors.black)
  45. end
  46.  
  47. function clearScreen(ccolor,ecolor, mon)
  48.     mon.setBackgroundColor(ccolor)
  49.     mon.clear()
  50.     mon.setBackgroundColor(ecolor)
  51. end
  52.  
  53. function toggleRedstone(side)
  54.     if redstone.getOutput(side) then
  55.         redstone.setAnalogOutput(side, 0)
  56.     else
  57.         redstone.setAnalogOutput(side, 15)
  58.     end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment