m-mueller678

ore scanner

Jul 31st, 2021 (edited)
1,124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. local component=require('component')
  2. local debug=component.debug
  3. local world=debug.getWorld()
  4.  
  5. local px=math.floor(debug.getX()/16)
  6. local pz=math.floor(debug.getZ()/16)
  7.  
  8. function scan_chunk(cx,cz)
  9.   if math.abs(cx%3)~=1 or math.abs(cz%3)~=1 then
  10.     return
  11.   end
  12.   for ox=7,9 do
  13.     for oz=7,9 do
  14.       for y=math.random(5),120,5 do
  15.         local result=handle_block_state(world.getBlockState(cx*16+ox,y,cz*16+oz))
  16.         if result then
  17.           print(x,y,z,result)
  18.         end
  19.       end
  20.     end
  21.   end
  22. end
  23.  
  24. for d2=0,50 do
  25.   local d=math.sqrt(d2)
  26.   print('d= '..d,d2)
  27.   for dx=-math.ceil(d),math.ceil(d) do
  28.         local abs_dz=math.floor(math.sqrt(d2-dx*dx)+0.5)
  29.     if abs_dz*abs_dz+dx*dx == d2 then
  30.       print(dx,abs_dz)
  31.       scan_chunk(px+dx,pz-abs_dz)
  32.       scan_chunk(px+dx,pz+abs_dz)
  33.     end
  34.     end
  35. end
  36.  
  37. function map_block_state(state)
  38.     return  state:match('^gregtech:ore_(%a*)')
  39. end
  40.  
  41. for x=px-h_range,px+h_range,h_step do
  42.     for z=pz-h_range,pz+h_range,h_step do
  43.         for y=0,y_max,v_step do
  44.             local result=handle_block_state(world.getBlockState(x,y,z))
  45.             if result then
  46.                 print(x,y,z,result)
  47.             end
  48.         end
  49.     end
  50. end
Add Comment
Please, Sign In to add comment