Advertisement
Guest User

Untitled

a guest
Jan 1st, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #SOURCE()
  2.  
  3. #GLIBFUNC(module/netlib.lua, loadModem)
  4. #GLIBFUNC(module/netlib.lua, openPort)
  5. #GLIBFUNC(module/netlib.lua, listen)
  6. #GLIBFUNC(module/netlib.lua, listenStop)
  7. #GLIBFUNC(module/netlib.lua, closePort)
  8. #IMPORTLIB(module/netlib.lua, bcNet)
  9.  
  10. #GLIBFUNC(module/selfdestroy.lua, onAnyContact)
  11. #GLIBFUNC(module/selfdestroy.lua, now)
  12. #IMPORTLIB(module/selfdestroy.lua, bcDestroy)
  13.  
  14. #GLIBFUNC(module/turtle.lua, refuelAll)
  15. #GLIBFUNC(module/turtle.lua, forward)
  16. #GLIBFUNC(module/turtle.lua, turnRight)
  17. #IMPORTLIB(module/turtle.lua, bcTurtle)
  18.  
  19. local net = loadstring(bcNet)()
  20. local destroy = loadstring(bcDestroy)()
  21. local worker = loadstring(bcTurtle)()
  22.  
  23. local modem = net.loadModem("left")
  24.  
  25. if modem == false then
  26. printError("Unable to setup modem")
  27. return
  28. end
  29.  
  30. net.openPort(modem, 26345)
  31. local fListner, nListner = net.listen(modem, 26345)
  32. worker.refuelAll()
  33.  
  34. if fListner == false then
  35. printError("Unable to setup listner")
  36. return
  37. end
  38.  
  39. os.sleep(1)
  40. destroy.onAnyContact()
  41.  
  42. parallel.waitForAny(
  43. function()
  44. while true do
  45. worker.forward()
  46. worker.turnRight()
  47.  
  48. os.sleep(0)
  49. end
  50. end,
  51. function()
  52. while true do
  53. local _, nid, _, message =
  54. os.pullEvent(net.listenEvent)
  55.  
  56. if nid == nListner then
  57. break
  58. end
  59. end
  60. end,
  61. fListner)
  62.  
  63. net.listenStop(modem, 26345)
  64. net.closePort(modem, 26345)
  65. destroy.now()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement