Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Code for computer which displays destinations
- display_receive_channel = 4
- -- Start peripherals
- display = peripheral.wrap("left")
- modem = peripheral.wrap("bottom")
- modem.open(display_receive_channel)
- function clear_print(text)
- y_size, x_size = display.getSize()
- x_pos = (x_size - string.len(text)) / 2 + 6
- y_pos = y_size / 2 - 5
- --print(x_size.." "..y_size.." "..x_pos.." "..y_pos)
- print(text)
- display.clear()
- display.setCursorPos(x_pos, y_pos)
- display.write(text)
- end
- last_pressed = 0
- while true do
- local event, modemSide, senderChannel, replyChannel,
- message, senderDistance = os.pullEvent("modem_message")
- last_pressed = tonumber(message)
- if last_pressed == 0 then clear_print("No Destination")
- elseif last_pressed == 1 then clear_print("Sacred Oak")
- elseif last_pressed == 2 then clear_print("Redwood")
- elseif last_pressed == 3 then clear_print("Destination 3")
- elseif last_pressed == 4 then clear_print("Destination 4")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement