Advertisement
ecco7777

CC Plethora Neural Interface Mining Guide

Jun 13th, 2021 (edited)
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. filter="applied"
  2. meta=0
  3. scanner=peripheral.wrap("back")
  4. function getAngle(x,y)
  5.     return (180/math.pi)*math.atan(y,x)
  6. end
  7.  
  8. function getDistance(block)
  9.     vec=vector.new(block.x,block.y,block.z)
  10.     return vec.length(vec)
  11. end
  12.  
  13. function moveTo(x,y,z)
  14.     if x~=0 then
  15.         xa=0
  16.         if x>0 then xa=-90 elseif x<0 then xa=90 end
  17.         scanner.launch(xa,0,0.2)
  18.     end
  19.     if z~=0 then
  20.         xa=0
  21.         if z>0 then xa=0 elseif z<0 then xa=180 end
  22.         scanner.launch(xa,0,0.2)
  23.     end
  24. end
  25.  
  26. while true do
  27.     blocks={}
  28.     for _, block in pairs(scanner.scan()) do
  29.         if string.find(block.name,filter) and block.metadata==meta then
  30.             table.insert(blocks,block)
  31.         end
  32.  
  33.     end
  34.     table.sort(blocks,function(a,b) return getDistance(a)<getDistance(b) end)
  35.     if #blocks>0 then
  36.         block=blocks[1]
  37.         msg=(("The block at %d, %d, %d is %s"):format(block.x, block.y, block.z, block.name))
  38.         scanner.tell(msg)
  39.         moveTo(block.x,block.y,block.z)
  40.         print(msg)
  41.     end
  42.     sleep(0.5)
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement