Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1, 1)
- term.write("loading VR")
- local mid = {285, 58, 1604}
- local maxspace = {4, 2, 4}
- local pers = peripheral.wrap("back")
- local c = pers.canvas()
- local RGB = require("cRGB")
- local b = require("button").terminal
- rednet.open("right")
- pers.canvas3d().clear()
- local function center()
- c3d = pers.canvas3d().create()
- local x, y, z = gps.locate()
- local wanted = mid
- c3d.recenter(
- {
- wanted[1] - x - 1,
- wanted[2] - y - 3,
- wanted[3] - z - 1
- }
- )
- end
- center()
- c.clear()
- sleep(1)
- local rect = c.addRectangle(1, 1, 42, 15)
- local text = c.addText({3, 5}, "")
- text.setColor(RGB.conv(colors.white))
- text.setText("loading...")
- local function VR()
- rect.setColor(RGB.conv(colors.red))
- local function renderroom()
- rednet.send(165, "l 32 32 32")
- sleep(3)
- walls = {}
- function wallsrender()
- walls[1] = c3d.addBox(-3, 3.9, -3, 9, 0.1, 9)
- walls[2] = c3d.addBox(6, 0.5, -3, -9.1, 3.9, 0.1)
- walls[3] = c3d.addBox(6, 0.5, 5.9, -9, 3.9, 0.1)
- walls[4] = c3d.addBox(5.8, 0.5, 6, 0.1, 3.9, -9)
- walls[5] = c3d.addBox(-2.8, 0.5, 6, 0.1, 3.9, -9)
- walls[6] = c3d.addBox(-3, 0.5, -3, 9, 0.1, 9)
- end
- wallsrender()
- for i = 1, 51 do
- for x = 1, 6 do
- walls[x].setAlpha(i * 5)
- end
- sleep(0.05)
- end
- end
- renderroom()
- ---------SETUP------------
- -- local test = c3d.addBox(1, 2, 1, 1, 1, 1)
- local item = c3d.addItem({1,2,1,2},"computercraft:computer")
- --test.setColor(RGB.conv(colors.red))
- --------------------------
- while true do
- local click = b.timetouch(0.1)
- local pos = {gps.locate(0.05)}
- if next(pos) then
- pos = {
- math.min(math.floor(pos[1] - mid[1]), maxspace[1]),
- math.min(math.ceil(pos[2] - mid[2]), maxspace[2]),
- math.min(math.floor(pos[3] - mid[3]), maxspace[3])
- }
- pos = {
- math.max(pos[1], maxspace[1] - maxspace[1] * 2),
- math.max(pos[2], maxspace[2] - maxspace[2] * 2),
- math.max(pos[3], maxspace[3] - maxspace[3] * 2)
- }
- end
- text.setText(table.concat(pos, " "))
- term.clear()
- term.setCursorPos(1,2)
- print("if this doesnt work spam |exit VR| until it does")
- if b.button(1, click, 1, 1, "exit VR") then
- pers.canvas3d().clear()
- center()
- wallsrender()
- for i = 1, 51 do
- for x = 1, 6 do
- walls[x].setAlpha(255 - i * 5)
- end
- sleep(0.05)
- end
- rednet.send(165, "l 0 0 0")
- error("VR ENDED", 0)
- term.clear()
- end
- -----------main-----------
- local gp = {item.getPosition()}
- if gp[1] > 3 then
- state = false
- elseif gp[1] < 1 then
- state = true
- end
- if state then
- item.setPosition(gp[1]+0.1,gp[2],gp[3])
- else
- item.setPosition(gp[1]-0.1,gp[2],gp[3])
- end
- --------------------------
- end
- end
- local ok, err = pcall(VR)
- if not ok then
- term.clear()
- print("VR has stopped:\n" .. err)
- pers.canvas3d().clear()
- pers.canvas().clear()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement