Advertisement
9551

Untitled

Jul 5th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. local arg = ...
  2. term.clear()
  3. term.setCursorPos(1, 1)
  4. term.write("loading VR")
  5. local maxspace = {4, 2, 4}
  6. local pers = peripheral.wrap("back")
  7. local c = pers.canvas()
  8. local RGB = require("./cRGB")
  9. local b = require("./button").terminal
  10. rednet.open("right")
  11. pers.canvas3d().clear()
  12. local function center()
  13. c3d = pers.canvas3d().create()
  14. local x, y, z = gps.locate()
  15. local wanted = mid
  16. c3d.recenter(
  17. {
  18. wanted[1] - x - 1,
  19. wanted[2] - y - 3,
  20. wanted[3] - z - 1
  21. }
  22. )
  23. end
  24. if not arg then
  25. arg = dcolor
  26. end
  27. center()
  28. c.clear()
  29. sleep(1)
  30. local rect = c.addRectangle(1, 1, 42, 15)
  31. local text = c.addText({3, 5}, "")
  32. text.setColor(RGB.conv(colors.white))
  33. text.setText("loading...")
  34. local function playNote(ins,vol,pitch)
  35. rednet.send(maincompID,"API",ins,vol,pitch)
  36. end
  37. local function VR()
  38. rect.setColor(RGB.conv(colors.red))
  39. local function renderroom()
  40. rednet.send(maincompID, "l 32 32 32")
  41. sleep(3)
  42. walls = {}
  43. function wallsrender()
  44. walls[1] = c3d.addBox(-3, 3.9, -3, 9, 0.1, 9)
  45. walls[2] = c3d.addBox(6, 0.5, -3, -9.1, 3.9, 0.1)
  46. walls[3] = c3d.addBox(6, 0.5, 5.9, -9, 3.9, 0.1)
  47. walls[4] = c3d.addBox(5.8, 0.5, 6, 0.1, 3.9, -9)
  48. walls[5] = c3d.addBox(-2.8, 0.5, 6, 0.1, 3.9, -9)
  49. walls[6] = c3d.addBox(-3, 0.5, -3, 9, 0.1, 9)
  50. end
  51. wallsrender()
  52. for i = 1, 51 do
  53. for x = 1, 6 do
  54. walls[x].setAlpha(i * 5)
  55. walls[x].setColor(RGB.conv(colors[arg]))
  56. end
  57. sleep(0.05)
  58. end
  59. end
  60. renderroom()
  61. setup()
  62. while true do
  63. local click = b.timetouch(0.1)
  64. local pos = {gps.locate(0.05)}
  65. local safety = pos
  66. if next(pos) then
  67. pos = {
  68. math.min(math.floor(pos[1] - mid[1]), maxspace[1]),
  69. math.min(math.ceil(pos[2] - mid[2]), maxspace[2]),
  70. math.min(math.floor(pos[3] - mid[3]), maxspace[3])
  71. }
  72. pos = {
  73. math.max(pos[1], maxspace[1] - maxspace[1] * 2),
  74. math.max(pos[2], maxspace[2] - maxspace[2] * 2),
  75. math.max(pos[3], maxspace[3] - maxspace[3] * 2)
  76. }
  77. end
  78. text.setText(table.concat(pos, " "))
  79. term.clear()
  80. term.setCursorPos(1, 2)
  81. print("if this doesnt work spam |exit VR| until it does")
  82. if b.button(1, click, 1, 1, "exit VR") then
  83. pers.canvas3d().clear()
  84. center()
  85. wallsrender()
  86. for i = 1, 51 do
  87. for x = 1, 6 do
  88. walls[x].setAlpha(255 - i * 5)
  89. walls[x].setColor(RGB.conv(colors[arg]))
  90. end
  91. sleep(0.05)
  92. end
  93. error("VR ENDED", 0)
  94. term.clear()
  95. end
  96. main()
  97. end
  98. end
  99.  
  100. local ok, err = pcall(VR)
  101. if not ok then
  102. term.clear()
  103. print("VR has stopped:\n" .. err)
  104. pers.canvas3d().clear()
  105. if err ~= "VR ENDED" then
  106. center()
  107. wallsrender()
  108. for i = 1, 51 do
  109. for x = 1, 6 do
  110. walls[x].setAlpha(255 - i * 5)
  111. walls[x].setColor(RGB.conv(colors[arg]))
  112. end
  113. sleep(0.05)
  114. end
  115. end
  116. rednet.send(maincompID, "l 0 0 0")
  117. rednet.send(1maincompID, "end")
  118. pers.canvas().clear()
  119. end
  120.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement