Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Code for computer which receives destinations
- --It then outputs redstone on a certain side and activates a command block
- receive_channel = 3
- display_transmit_channel = 4
- last_pressed = 0
- -- Start modem
- local modem = peripheral.wrap("bottom")
- modem.open(receive_channel)
- -- Wrap command block
- local commandBlock = peripheral.wrap("top")
- function run_command(side)
- if side == 1 then commandBlock.setCommand("tp @p[r=5] -1321 64 528")
- elseif side == 2 then commandBlock.setCommand("tp @p[r=5] -123 64 53")
- elseif side == 3 then commandBlock.setCommand("tp @p[r=5] -1493 63 644")
- elseif side == 4 then commandBlock.setCommand("tp @p[r=5] -1497 63 640")
- elseif side == 0 then print("No destination set")
- else print("Side is wrong format! ", side)
- end
- commandBlock.runCommand()
- end
- function pressure_plate()
- -- Wait for pressure plate input on front
- -- Upon receiving it, send a redstone_pulse
- while redstone.getInput("left") == false do
- sleep(0.1)
- end
- run_command(last_pressed)
- print("tp to destination "..last_pressed)
- end
- function modem_wait()
- local event, modemSide, senderChannel, replyChannel,
- message, senderDistance = os.pullEvent("modem_message")
- last_pressed = tonumber(message)
- disp_print(last_pressed)
- print(last_pressed)
- end
- function disp_print(text)
- modem.transmit(display_transmit_channel, 1, text)
- end
- while true do
- parallel.waitForAny(pressure_plate, modem_wait)
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement