kerrnel

Mu Lamda API - v1.0

Jun 15th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. -- Mu Lambda API v1.0
  2. -- by MCKerrnel
  3. --
  4. -- YouTube: http://www.youtube.com/MCKerrnel
  5. -- Twitter: @MCKerrnel
  6. --
  7. -- This is a set of common functions that
  8. -- most of the system programs will use.
  9.  
  10. -- Always set the monitor peripheral.
  11. local monitor = peripheral.wrap("back")
  12.  
  13. -- A generic function to allow us to print text
  14. -- to the monitor at a specific location and in
  15. -- a specific color.
  16. function tp(textToPrint, column, row, fgcolour, bgcolour)
  17. monitor.setCursorPos(column, row)
  18. monitor.setTextColor(fgcolour)
  19. monitor.setBackgroundColor(bgcolour)
  20. monitor.write(textToPrint)
  21. end
  22.  
  23. -- Clears the monitor.
  24. function clear()
  25. monitor.setCursorPos(0, 0)
  26. monitor.setTextColor(colors.white)
  27. monitor.setBackgroundColor(colors.black)
  28. monitor.clear()
  29. end
  30.  
  31. -- Menu Box
  32. -- This function will create a clickable region
  33. -- in a box format. You provide it with the
  34. -- dimensions, label, and colour palette, and
  35. -- it will return a table with the clickable
  36. -- dimensions.
  37. function menuBox(title, boxFG, boxBG, textFG, textBG, xA, yA, width, height)
  38. drawBox(boxFG, boxBG, xA, yA, width, height)
  39. tp(title, xA + 2, yA + 2, textFG, textBG)
  40. end
  41.  
  42. -- Draws just a box.
  43. function drawBox(boxFG, boxBG, xA, yA, width, height)
  44. local bline = ""
  45.  
  46. for hCount = 0, height - 1, 1 do
  47. bline = ""
  48. for wCount = 1, width, 1 do
  49. bline = bline.." "
  50. end
  51. tp(bline, xA, yA + hCount, boxFG, boxBG)
  52. end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment