Advertisement
asteroidsteam

guiapi

Dec 13th, 2016
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. function drawscreen(color)
  2. if color == nil then
  3. write("Error: nil color!")
  4. else
  5. term.setBackgroundColor(color)
  6. term.clear()
  7. term.setCursorPos(0, 0)  
  8. term.setBackgroundColor(colors.black)
  9. end
  10. end
  11. function drawTextBox(x, y, bg, text)
  12. if bg == nil then
  13. write("Error: Nil bg!")
  14. else
  15. if y == nil then
  16. write("Error: Nil y!")
  17. else
  18. if x == nil then
  19. write("Error: Nil x!")
  20. else
  21. if text == nil then
  22. write("Error: Nil Text!")
  23. else
  24. term.setBackgroundColor(bg)
  25. term.setCursorPos(x, y)
  26. local text1 = tostring(text)
  27. write(text1)
  28. term.setBackgroundColor(colors.black)
  29. end
  30. end
  31. end
  32. end
  33. end
  34. function drawImage(path, x, y)
  35. if y == nil then
  36. write("Error: Nil y!")
  37. else
  38. if x == nil then
  39. write("Error: Nil x!")
  40. else
  41. if path == nil then
  42. write("Error: Nil path!")
  43. else
  44. local image = paintutils.loadImage(path)
  45. paintutils.drawImage(image, x, y)
  46. end
  47. end
  48. end
  49. end
  50. function cdrawTextBox(txt, color)
  51. if color == nil then
  52. print("Error: Nil color!")
  53. else
  54. if txt == nil then
  55. print("Error: Nil text!")
  56. else
  57. local w,h = term.getSize()
  58. midw, midh = math.floor(w-#txt)/2,math.floor(h/2)
  59. term.setCursorPos(midw,midh)
  60. term.setBackgroundColor(color)
  61. write(txt)
  62. while true do
  63. local event, button, cx, cy = os.pullEvent("mouse_click")
  64. if cx >= midw and cx < txt:len() and cy == midh then
  65. --code after button clicked
  66.  
  67. --end code after button clicked
  68. break
  69. end
  70. end
  71.  
  72.  
  73. end
  74. end
  75. end
  76. function drawDesktopImg(path)
  77. local image = paintutils.loadImage(path)
  78. paintutils.drawImage(image, 1, 1)
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement