Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clientsSuccseeded = 0
- clientsAmount = 0
- modem = peripheral.find("modem")
- transmitChannel = 229
- receiveChannel = 228
- modem.closeAll()
- modem.open(receiveChannel)
- local function mainLoop()
- while true do
- if clientsSuccseeded == clientsAmount then
- modem.transmit(transmitChannel, transmitChannel, "continue")
- clientsSuccseeded = 0
- end
- print("clientsSuccseeded", clientsSuccseeded)
- sleep(1)
- end
- end
- local function receiveClientMessages()
- while true do
- local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- print(message)
- if message == "completedTurn" then
- print("Recieved completed message from client")
- clientsSuccseeded = clientsSuccseeded + 1
- end
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("How many clients are there?")
- clientsAmount = tonumber(io.stdin:read())
- term.clear()
- term.setCursorPos(1, 1)
- print("Press any button to start")
- os.pullEvent("key")
- term.clear()
- term.setCursorPos(1, 1)
- print("Started")
- modem.transmit(transmitChannel, transmitChannel, "start")
- parallel.waitForAny(mainLoop, receiveClientMessages)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement