Advertisement
tima_gt

tde-redstone 1.1 [OpenComputers]

Apr 12th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. local event = require("event")
  2. local component = require("component")
  3. local sides = require("sides")
  4. local term = require("term")
  5. local gpu = component.gpu
  6. local redstone = component.redstone
  7. local colors = require("colors")
  8. local w, h = gpu.getResolution()
  9. gpu.setBackground(0xFFFFFF)
  10. gpu.setForeground(0xFF0000)
  11. gpu.fill(1, 1, w, h, " ")
  12. term.setCursor(1, 1)
  13. io.write("[X]")
  14. redstone_on = false
  15. while true do
  16. if redstone_on then
  17. gpu.setBackground(0xFFFF00)
  18. gpu.setForeground(0xFFFFFF)
  19. gpu.fill((w / 2 / 2) - 10, h / 2 - 10, (w / 2 / 2) + 10, h / 2 + 10, " ")
  20. gpu.setBackground(0xFF0000)
  21. gpu.setForeground(0xFFFFFF)
  22. fakel1 = ((w/ 2 /2 )) / 2 + 10
  23. fakel2 =  h /2 - 9
  24. fakel3 = ((w / 2 / 2) - 10) / 2 + 4
  25. fakel4 =  h / 2 - 5
  26. gpu.fill(fakel1, fakel2, fakel3, fakel4, " ")
  27. gpu.setBackground(0xFFCC00)
  28. fakel1 = ((w / 2 / 2) / 2 + 10)
  29. fakel2 = h / 2 - 5 + 1
  30. fakel3 = ((w / 4) - 10) / 2 + 4
  31. fakel4 = h / 2 + 3
  32. gpu.fill(fakel1, fakel2, fakel3, fakel4, " ")
  33. else
  34. gpu.setBackground(0xFF0000)
  35. gpu.setForeground(0xFFFFFF)
  36. gpu.fill((w / 2 / 2) - 10, h / 2 - 10, (w / 2 / 2) + 10, h / 2 + 10, " ")
  37. gpu.setBackground(0xFFFF00)
  38. gpu.setForeground(0xFFFFFF)
  39. fakel1 = ((w/ 2 /2 )) / 2 + 10
  40. fakel2 =  h /2 - 9
  41. fakel3 = ((w / 2 / 2) - 10) / 2 + 4
  42. fakel4 =  h / 2 - 5
  43. gpu.fill(fakel1, fakel2, fakel3, fakel4, " ")
  44. gpu.setBackground(0xFFCC00)
  45. fakel1 = ((w / 2 / 2) / 2 + 10)
  46. fakel2 = h / 2 - 5 + 1
  47. fakel3 = ((w / 4) - 10) / 2 + 4
  48. fakel4 = h / 2 + 3
  49. gpu.fill(fakel1, fakel2, fakel3, fakel4, " ")
  50. end
  51. local event, adress, arg1, arg2, arg3 = event.pull()
  52. if event == "touch" then
  53. X = arg1
  54. Y = arg2
  55. if X >= (w / 2 / 2) - 10 and X <= (w / 2 / 2) + 10 and Y >= h / 2 - 10 and Y <= h / 2 + 10 and redstone_on then
  56. redstone_on = false
  57. redstone.setOutput(sides.back, 0)
  58. elseif X >= (w / 2 / 2) - 10 and X <= (w / 2 / 2) + 10 and Y >= h / 2 - 10 and Y <= h / 2 + 10 and not redstone_on then
  59. redstone_on = true
  60. redstone.setOutput(sides.back, 100)
  61. elseif X >= 1 and X <= 3 and Y == 1 then
  62. break
  63. end
  64. end
  65. end
  66. redstone.setOutput(sides.back, 0)
  67. gpu.setBackground(0x000000)
  68. gpu.setForeground(0xFFFFFF)
  69. gpu.fill(1, 1, w, h, " ")
  70. term.setCursor(1, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement