Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local drive = 256
- local chest = peripheral.find("ender_chest")
- local spatialSide = "right"
- local spatial = peripheral.wrap(spatialSide)
- local chestPush = "east"
- local chestOpose = "west"
- local selected = 1
- local destinations = {
- {name="Ardron's room",frequency=258,},
- {name="ME System",frequency=257,},
- }
- local this = {name="Deep Dark Miner",frequency=259,}
- if fs.exists("event")==false then
- shell.run("pastebin get L7KYC10V event")
- end
- os.loadAPI("event")
- function storePlayer()
- redstone.setOutput(spatialSide,true)
- sleep(0.1)
- redstone.setOutput(spatialSide,false)
- spatial.pushItem(chestOpose,2,1,1)
- end
- function loadPlayer()
- setDestination(drive)
- redstone.setOutput(spatialSide,true)
- sleep(0.1)
- redstone.setOutput(spatialSide,false)
- spatial.pushItem(chestOpose,2,1,1)
- setDestination(this.frequency)
- end
- function getCell(frequency)
- chest.setFrequency(frequency)
- chest.pushItem(chestPush,1,1,1)
- end
- function setDestination(frequency)
- chest.setFrequency(frequency)
- end
- function teleport(destination)
- getCell(drive)
- setDestination(destinations[destination].frequency)
- storePlayer()
- setDestination(this.frequency)
- end
- function receiveTeleport()
- getCell(this.frequency)
- loadPlayer()
- end
- function drawPositions()
- term.clear()
- for i,data in ipairs(destinations) do
- term.setCursorPos(4,i)
- term.write(data.name)
- end
- end
- function drawSelection(old,new)
- term.setCursorPos(2,old)
- term.write(" ")
- term.setCursorPos(2,new)
- term.write(">")
- end
- function onkey(key)
- if key==200 then
- --up
- if selected>1 then
- selected = selected - 1
- end
- drawSelection(selected + 1, selected)
- elseif key==208 then
- --down
- if #destinations>selected then
- selected = selected +1
- end
- drawSelection(selected - 1, selected)
- elseif key==28 then
- --enter
- teleport(selected)
- end
- end
- event.addHandler("key",onkey)
- function checkPendingTeleports()
- local item = chest.getStackInSlot(1)
- if item==nil then return end
- receiveTeleport()
- end
- event.addHandler("timer",checkPendingTeleports)
- drawPositions()
- drawSelection(1,1)
- while true do
- event.handleCCEvents(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement