Advertisement
SteamPunk_Devil

Rednet Test Client

Feb 5th, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 KB | None | 0 0
  1. --Setting Variables--
  2. local Screen = peripheral.wrap("right") -- connects to the monitor on the right and gives it the local variable Screen
  3. local ID = os.getComputerID() -- gets the computers ID
  4. local PartnerID = "0"
  5.  
  6. --Opens modem--
  7. rednet.open("top") -- Tells CC to use the modem on the top
  8.  
  9. -- Displays ID --
  10. Screen.clear() -- Clears the Screen
  11. Screen.setCursorPos(1,1) -- Resets the pos to start righting from
  12. Screen.write("My ID is "..ID) -- Writes "My ID is ID"  
  13.  
  14. -- Finds Partner --
  15. if PartnerID ~= "0" then-- opens if loop checking if partner ID is not 0
  16.     rednet.send(PartnerID, "ID") -- Sends ID to partners I
  17.         else -- runs if  partners ID is 0 so unreceived
  18.         while PartnerID == "0" do  -- while loop works intil partners ID is received
  19.             print("I have not got a message")
  20.             PartnerID = rednet.receive(59) -- Sets PartnerID to the message it receives (stupid I know but its just testing) or times out after 59 secs
  21.         end -- ends while loop
  22.        
  23. end         -- ends if loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement