Protocol73

netget.lua

Sep 26th, 2020
994
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Written by Protocol73 For ComputerCraft 1.6
  2. --Settings (Move to .cfg)
  3. modemside = "left"
  4. reciverID = nil
  5. protocol = nil
  6. hostname = "Test-55"
  7. Debug = true
  8.  
  9. --functions (Maybe move to P73_core_functions.lua)
  10.  
  11. function Debugger(debugItem, debugdata) --For Output of Debug Data
  12.     if Debug == true then
  13.         print("---DEBUGGING OUTPUT---")
  14.         print("Debug data from",debugItem)
  15.         print(debugdata)
  16.         print("---END DEBUGGING OUTPUT---")
  17.     else
  18.         --Output no debug info if false
  19.     end
  20. end
  21.  
  22. function RemoteRunLine(RunThis ,NETrepy2)
  23.     shell.run(RunThis)
  24.    
  25. end
  26.  
  27. --REDNET CODE
  28. rednet.open(modemside)
  29. NETsenderID, NETMessage, NETprotocol = rednet.receive()
  30.  
  31.  
  32. --Check Protocol of Data Received
  33. if NETprotocol == "TestNet" then
  34.     Debugger("Remote PC via TestNet:",NETMessage)
  35.     print("Received from PC-ID#",NETsenderID)
  36. elseif NETprotocol == "RemoteRun" then
  37.     NETrepy2 = NETsenderID
  38.     RemoteRunLine(NETMessage,NETrepy2)
  39. else
  40.     print("Got Message via unknown protocol")
  41.     if Debug == false then
  42.         print("Set Debug = true to see info")
  43.     else
  44.         Debugger(NETprotocol, NETMessage)
  45.     end
  46. end
RAW Paste Data