Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Capacitor Reader - Host")
- local channel = 69
- local secretWord = "himama"
- local secretWord2 = "hidada"
- local rsSide = "right"
- local updateDelay = 3
- local modem = peripheral.wrap("left")
- if (not modem) then
- print("Please connect a modem to the left")
- else
- print("Waiting to connect with client...")
- modem.open(channel)
- while true do
- local sub0, sub1, sub2, sub3, message, sub4 = os.pullEvent("modem_message")
- print("Received message: " .. message)
- if (message == secretWord) then
- modem.transmit(channel, 1, secretWord2)
- print("Connected. Sending Capacitor Updates")
- sleep(2)
- while true do
- term.clear()
- term.setCursorPos(1,1)
- local capacitorStatus = rs.getAnalogInput(rsSide)
- modem.transmit(channel, 1, capacitorStatus)
- print("Current Status: " .. capacitorStatus)
- sleep(updateDelay)
- end
- break
- else
- print("Received wrong password. Exiting...")
- break
- end
- end
- modem.close(channel)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement