Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Capacitor Reader Client")
- local channel = 70
- local rsSide = "back"
- local rsDefault = false
- rs.setOutput(rsSide, rsDefault)
- local capacityToActivate = 2
- local refilling = false
- local secretWord = "himama"
- local secretWord2 = "hidada"
- local modem = peripheral.wrap("left")
- if (not modem) then
- print("Please connect a modem")
- else
- print("Connecting with the host...")
- modem.transmit(channel, 1, secretWord)
- modem.open(channel)
- while true do
- local sub0, sub1, sub2, sub3, message, sub4 = os.pullEvent("modem_message")
- if message == secretWord2 then
- print("Connected")
- while true do
- local sub00, sub11, sub22, sub33, status = os.pullEvent("modem_message")
- local receivedStatus = tonumber(status)
- print("Received Status: " .. receivedStatus)
- if (receivedStatus < capacityToActivate) and not refilling then
- rs.setOutput(rsSide, not rsDefault)
- refilling = true
- end
- if (receivedStatus >= 14) and refilling then
- rs.setOutput(rsSide, rsDefault)
- refilling = false
- end
- end
- else
- print("WRONG PASSWORD, exiting..")
- break
- end
- end
- modem.close(channel)
- end
Add Comment
Please, Sign In to add comment