Advertisement
abstract_abstract

client.lua

Nov 6th, 2024
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. rednet.open("left")
  2.  
  3.  
  4.  
  5.  
  6.  
  7. local function registry()
  8.  
  9.     local name = arg[2]
  10.  
  11.     local id = os.getComputerID()
  12.  
  13.     local data = {name = name, id = id}
  14.  
  15.     local message = textutils.serialise(data)
  16.  
  17.  
  18.  
  19.     rednet.send(126, message, "dns_register")
  20.  
  21.  
  22.  
  23.     local senderID, message, protocol = rednet.receive("dns_ack")
  24.  
  25.     print(message)
  26.  
  27. end
  28.  
  29.  
  30.  
  31.  
  32.  
  33. local function getall()
  34.  
  35.     rednet.send(126, "", "dns_list")
  36.  
  37.     local senderID, message, protocol = rednet.receive("dns_list_response")
  38.  
  39.     print(message)
  40.  
  41.  
  42.  
  43. end
  44.  
  45.  
  46.  
  47.  
  48.  
  49. if #arg == 0 then
  50.  
  51.     print("No argements provided. Available commands:")
  52.  
  53.     print("1. reg [domain] - register a domain")
  54.  
  55.     print("2. getall - list all domains")
  56.  
  57.     return
  58.  
  59. end
  60.  
  61.  
  62.  
  63.  
  64.  
  65. if arg[1] == "reg" then
  66.  
  67.     registry()
  68.  
  69. elseif arg[1] == "getall" then
  70.  
  71.     getall()
  72.  
  73. end
  74.  
  75.  
  76.  
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement