Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Teleporter v2.0
- if (fs.exists("tp_settings") ~= true) then
- local f = fs.open("tp_settings","w")
- f.write([[local modem = "top"
- local port = "tilespatialioport_4"
- local chest = "right"
- local pipe = "bottom"
- local rtele = "front"
- local rdir = "south"
- return modem, port, chest, pipe, rtele, rdir]])
- f.close()
- error("Settings not setup.",0)
- else
- local f = fs.open("tp_settings","r")
- local f2 = f.readAll()
- f.close()
- modem, port, chest, pipe, rtele, rdir = loadstring(f2)()
- end
- rednet.open(modem)
- function pulse(side)
- sleep(0.5)
- rs.setOutput(side,true)
- sleep(0.5)
- rs.setOutput(side,false)
- sleep(0.5)
- end
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("Wii's Teleship Port v2.0")
- print("ID: "..os.getComputerID())
- print("Press any key to bring up teleport prompt.")
- local event, idd, msg = os.pullEvent()
- if (event == "key") then
- --print("Teleporter v2.0")
- write("Countdown: ")
- count = tonumber(read())
- repeat
- write("Storage device slot: ")
- slot = tonumber(read())
- until peripheral.call(chest,"getStackInSlot",slot) ~= nil
- write("(0 for same) Teleporter ID: ")
- id = tonumber(read())
- write("(0 for infinite) Teleport time: ")
- time = tonumber(read())
- for i = count, 1, -1 do
- print(i.."...")
- sleep(1)
- end
- peripheral.call(port,"pullItemIntoSlot",rdir,slot,1,1)
- sleep(0.2)
- pulse(rtele)
- --peripheral.call(port,"swapStacks",1,2)
- if (time > 0) then
- for i = time, 1, -1 do
- print(i.."...")
- sleep(1)
- end
- peripheral.call(port,"swapStacks",1,2)
- sleep(0.2)
- pulse(rtele)
- sleep(0.2)
- pulse(pipe)
- repeat
- sleep(0.2)
- until peripheral.call(chest,"getStackInSlot",slot) ~= nil
- if (id > 0) then
- rednet.send(id,"tp"..slot)
- ia, msg = rednet.receive(3)
- print(msg)
- sleep(2)
- if (msg ~= "ready") then
- peripheral.call(port,"pullItemIntoSlot",rdir,slot,1,1)
- --port.swapStack(1,2)
- sleep(0.1)
- pulse(rtele)
- sleep(0.2)
- pulse(pipe)
- end
- end
- else
- sleep(0.5)
- pulse(pipe)
- end
- elseif (event == "rednet_message") then
- --event,idd,msg
- if (string.sub(msg,1,2) == "tp") then
- local thing = tonumber(string.sub(msg,3))
- rednet.send(idd,"ready")
- repeat
- sleep(0.1)
- until peripheral.call(chest,"getStackInSlot",thing) ~= nil
- peripheral.call(port,"pullItemIntoSlot",rdir,thing,1,1)
- sleep(0.5)
- pulse(rtele)
- sleep(0.5)
- pulse(pipe)
- sleep(0.5)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment