Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Uplink Program (No Interference with Slot Machine)
- local modem = peripheral.find("modem")
- if not modem then error("No modem found. Please attach a wireless modem.") end
- -- Set uplink channels (different from slot machine)
- local uplinkChannel = 2 -- Uplink uses channel 2 for communication
- local serverChannel = 1 -- Server communication on channel 1
- modem.open(uplinkChannel)
- -- Function to relay messages between server and client without interference
- local function relayMessage()
- while true do
- local event, side, senderChannel, replyChannel, message, distance = os.pullEvent("modem_message")
- -- Ensure we only process messages on the uplink channel
- if senderChannel == uplinkChannel then
- -- Forward the message to the server (relay)
- modem.transmit(serverChannel, uplinkChannel, message)
- elseif senderChannel == serverChannel then
- -- Forward the message back to the client (uplink to client)
- modem.transmit(uplinkChannel, serverChannel, message)
- end
- end
- end
- -- Start message relay
- print("Uplink is active and relaying messages.")
- relayMessage()
Advertisement
Add Comment
Please, Sign In to add comment