This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
mrpoopy345's profile picture

[solved] Empty Variables

Started by mrpoopy345, 15 November 2013 - 04:21 PM
mrpoopy345 #1
Posted 15 November 2013 - 05:21 PM
So, i made a password door with a server. So, my current setup is (I know I am noobish, but do not tell me my code is too complicated unless you need to.)
The client will send whatever the user put in to the server. The server, which has the password stored in it, will, if the password is right, will send "true" to the client. If it is not right, it will send "false". The client will output a redstone signal for 2 seconds if the message received is true, but if it is false, it will say "Incorrect" and reboot. What I want to make it do is if the client does not get any response, it will say the server is not active. Help? If you need more info, feel free to tell me.
Edited on 16 November 2013 - 08:52 AM
jay5476 #2
Posted 15 November 2013 - 06:27 PM
1. post you current code
2. luckily i think i can help still
im guessing you have this somewhere

id,mes,dis = rednet.receive()
now you want to test if you get no response so we can do this

rednet.receive(timeout) --# timeout is a number
now after timeout number of seconds it will continue on and return nil
so try something like this

id,mes,distance = rednet.receive(15)
if not id then
  print("Couldn't connect!")
end
--# other code here
mrpoopy345 #3
Posted 16 November 2013 - 09:52 AM
Thank you! :DDD