Advertisement
abstract_abstract

client.lua

Oct 14th, 2024
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. rednet.open("left")
  2.  
  3.  
  4. local function registry()
  5.     local name = arg[2]
  6.     local id = os.getComputerID()
  7.     local data = {name = name, id = id}
  8.     local message = textutils.serialise(data)
  9.  
  10.     rednet.send(126, message, "dns_register")
  11.  
  12.     local senderID, message, protocol = rednet.receive("dns_ack")
  13.     print(message)
  14. end
  15.  
  16.  
  17. local function getall()
  18.     rednet.send(126, "", "dns_list")
  19.     local senderID, message, protocol = rednet.receive("dns_list_response")
  20.     print(message)
  21.  
  22. end
  23.  
  24.  
  25. if #arg == 0 then
  26.     print("No argements provided. Available commands:")
  27.     print("1. reg [domain] - register a domain")
  28.     print("2. getall - list all domains")
  29.     return
  30. end
  31.  
  32.  
  33. if arg[1] == "reg" then
  34.     registry()
  35. elseif arg[1] == "getall" then
  36.     getall()
  37. end
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement