Advertisement
Blackhome

inspect

Jan 6th, 2025
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | Gaming | 0 0
  1. -- returns true if the block in this directions is in the given array
  2. local function Forward(arr)
  3.     local bBlockForward, data = turtle.inspect()
  4.     local blockname = data.name
  5.     if bBlockForward then
  6.         for i = 1, #arr, 1 do
  7.             if blockname == arr[i] then
  8.                 if blockname == "minecraft:lava" then
  9.                     local level = data.state.level
  10.                     if not (level == 0) then
  11.                         return false
  12.                     end
  13.                 end
  14.                 return true
  15.             end
  16.         end
  17.     end
  18.     return false
  19. end
  20.  
  21. local function Up(arr)
  22.     local bBlockUp, data = turtle.inspectUp()
  23.     local blockname = data.name
  24.     if bBlockUp then
  25.         for i = 1, #arr, 1 do
  26.             if blockname == arr[i] then
  27.                 if blockname == "minecraft:lava" then
  28.                     local level = data.state.level
  29.                     if not (level == 0) then
  30.                         return false
  31.                     end
  32.                 end
  33.                 return true
  34.             end
  35.         end
  36.     end
  37.     return false
  38. end
  39.  
  40. local function Down(arr)
  41.     local bBlockDown, data = turtle.inspectDown()
  42.     local blockname = data.name
  43.     if bBlockDown then
  44.         for i = 1, #arr, 1 do
  45.             if blockname == arr[i] then
  46.                 if blockname == "minecraft:lava" then
  47.                     local level = data.state.level
  48.                     if not (level == 0) then
  49.                         return false
  50.                     end
  51.                 end
  52.                 return true
  53.             end
  54.         end
  55.     end
  56.     return false
  57. end
  58.  
  59. return { Forward = Forward, Up = Up, Down = Down}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement