AnonymusHochgenuss

worker

Jul 15th, 2021 (edited)
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. rednet.open("right")
  2. shell.run("updater")
  3. function check()
  4.  id, text = rednet.receive(2)
  5. end
  6. function checkup()
  7.  text = false
  8.  if not e then
  9.   while not text do
  10.    check()
  11.   end
  12.  else
  13.   for i=1,e do
  14.    if not text then
  15.     check()
  16.    end
  17.   end
  18.  end
  19. end
  20. function locate()
  21.  x, y, z = gps.locate()
  22. end
  23. while true do
  24.  e=false
  25.  checkup()
  26.  if text[1] == "tgoto" then
  27.   print("movement requested")
  28.   x3=tonumber(text[2])
  29.   y3=tonumber(text[3])
  30.   z3=tonumber(text[4])
  31.   if not text[5] then
  32.    print("no facing direction setted")
  33.    print("default facing: north")
  34.    fzyx="north"
  35.   else
  36.    fzyx=text[5]
  37.   end
  38.   print("goto "..x3..", "..y3..", "..z3)
  39.   locate()
  40.   shell.run("goto "..x.." 100 "..z)
  41.   print("requesting chunkloader turtle")
  42.   rednet.broadcast("chunkloader")
  43.   text=false
  44.   t=0
  45.   while t < 1 do
  46.    e=10
  47.    checkup()
  48.    e=false
  49.    if text == "available" then
  50.     t=1
  51.    else
  52.     rednet.broadcast("chunkloader")
  53.    end
  54.    if text == "available" then
  55.     id1=id
  56.     locate()
  57.     rednet.send(id,"goto")
  58.     rednet.send(id,x)
  59.     rednet.send(id,"101")
  60.     rednet.send(id,z)
  61.    end
  62.   end
  63.   text=false
  64.   while not text == "ready" and id == id1 do
  65.    checkup()
  66.   end
  67.   rednet.broadcast("chunkloader")
  68.   text=false
  69.   t=0
  70.   while t < 1 do
  71.    e=10
  72.    checkup()
  73.    e=false
  74.    if text == "available" then
  75.     t=1
  76.    else
  77.     rednet.broadcast("chunkloader")
  78.    end
  79.    if text == "available" then
  80.     id1=id
  81.     locate()
  82.     rednet.send(id1,"goto")
  83.     rednet.send(id1,x3)
  84.     rednet.send(id1,"101")
  85.     rednet.send(id1,z3)
  86.     print("going to "..x3.." "..y3.." "..z3.." "..fzyx)
  87.     shell.run("goto "..x3.." "..y3.." "..z3.." "..fzyx)
  88.    end
  89.   end
  90.   text=false
  91.   print("arrived")
  92.  elseif text[1] == "excavate" then
  93.   x2 = tonumber(text[2])
  94.   turtle.select(16)
  95.   turtle.turnRight()
  96.   turtle.turnRight()
  97.   turtle.place()
  98.   turtle.turnLeft()
  99.   turtle.turnLeft()
  100.   turtle.select(1)
  101.   shell.run("excavate")
  102.   sleep(60)
  103.   turtle.turnRight()
  104.   turtle.turnRight()
  105.   turtle.select(16)
  106.   turtle.dig()
  107.   turtle.turnLeft()
  108.   turtle.turnLeft()
  109.   turtle.select(1)
  110.  end
  111.  text = false
  112. end
Add Comment
Please, Sign In to add comment