Advertisement
Guest User

neuralReceive.lua

a guest
Apr 3rd, 2020
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. local modemSide = "top"
  2. local protocol = "neural_net"
  3. local timeout = 30
  4. local scriptPath = "tmp/"
  5.  
  6. local ni = peripheral.wrap("back")
  7. rednet.open(modemSide)
  8. rednet.host(protocol, ni.getName())
  9.  
  10. while true do
  11.     local senderId, msg, _ = rednet.receive(protocol, timeout)
  12.     if msg ~= nil then
  13.         local path = scriptPath .. msg.name
  14.         local file = fs.open(path, 'w')
  15.         file.write(msg.content)
  16.         file.close()
  17.         print(os.time() .. " -- received script " .. msg.name .. ".")
  18.         rednet.send(senderId, "Received", protocol)
  19.         shell.run(path)
  20.     end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement