TIMAS_Bro

browser.lua

Jun 17th, 2023
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rednet.open("top")
  2. while true do
  3.   term.setBackgroundColor(colors.black)
  4.   term.setTextColor(colors.white)
  5.   term.setCursorPos(1,1 )
  6.   term.clear()
  7.   print("\nDomain (or write dns):")
  8.   local domain = read()
  9.   if domain == "dns" then
  10.     print("Write id of new DNS: ")
  11.     local id = read()
  12.     local file = fs.open("/disk/id", "w")
  13.     file.writeLine(id)
  14.     print("ID written at "..id)
  15.     file.close()
  16.   end
  17.   local file = fs.open("/disk/id","r")
  18.   local id = tonumber(file.read())
  19.   file.close()
  20.   rednet.send(id, domain, "jnet")
  21.   print("Waiting for response!")
  22.   local senderId, message, protocol = rednet.receive()
  23.   local site = fs.open("/disk/tmp"..domain, "w")
  24.   site.write(message)
  25.   site.close()
  26.   if string.find(message, "printer`") then
  27.     local command,contents = string.match(message , "(%w+)`(%w+)")
  28.     print("Printing file 'File-printed-from: '"..domain)
  29.     shell.run("/disk/print", contents, "File-printed-from:"..domain)
  30.   elseif string.find(message, "error`") then
  31.     local command,contens = string.match(message , "(%w+)`(%w+)")
  32.     term.setTextColor(colors.red)
  33.     print(contens)
  34.   else
  35.     shell.run("/disk/tmp"..domain)
  36.   end
  37.   repeat
  38.     local event,key = os.pullEvent("key")
  39.   until key == keys.e
  40. function newLine()
  41.   xPos, yPos = term.getCursorPos()
  42.   term.setCursorPos(1,(yPos + 1))
  43. end
  44. end
Add Comment
Please, Sign In to add comment