Help making rednet receive more functional

Started by Asargos, Jan 29, 2022, 04:05 AM

Previous topic - Next topic

Asargos

I am still very new to lua and coding in general, but I have recently attempted at making a sort of private message network for a survival world I share with friends. Essentially, a computer creates a random string of numbers that it then confirms with all pc's used as password terminals, which prevents people from just remembering the password if they get access to a computer that spits out the code on demand. However, I have ran into an issue where, when requiring the rednet.receive library, I have to encase that entire block of code that interacts with it into a while true loop. Here is an example.

while true do
senderID, message = rednet.receive()
print("Current Authorization Code: " .. message)   
end

I have tried leaving out the loop, but the code seems to end and never receive the message. I have also tried adding a longer timeout to the receive time (entering a number in the argument field for the receive), however, none of these have worked for me. I know there must be a way to have it to where I can simply receive the message and then print it and end the program there, but I am unable to find it through multiple searches. All help is appreciated.

Lupus590

You've not called rednet.open and so rednet isn't authorised to use any modems.