hoodedperson

cook.lua

Apr 22nd, 2025 (edited)
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 0 0
  1. local whereWall = nil
  2. local curWall = nil
  3. local blockToWall = {
  4.   ["minecraft:stripped_oak_log"]=0,
  5.   ["minecraft:oak_log"]=1,
  6.   ["minecraft:bricks"]=2,
  7. }
  8. while whereWall == nil or curWall == nil do
  9.   local s,b = turtle.inspect()
  10.   if b.name == "minecraft:stripped_oak_log" or b.name == "minecraft:oak_log" or b.name == "minecraft:bricks" then
  11.     whereWall = 0
  12.     curWall = blockToWall[b.name]
  13.     break
  14.   else
  15.     turtle.turnLeft()
  16.   end
  17.  
  18. end
  19. print("Found wall: ", curWall)
  20.  
  21. function turnLeft()
  22.   turtle.turnLeft()
  23.   whereWall = (whereWall - 1) % 4
  24. end
  25. function turnRight()
  26.   turtle.turnRight()
  27.   whereWall = (whereWall + 1) % 4
  28. end
  29. function forward()
  30.   if whereWall % 2 == 0 then
  31.     return false, "may not escape 2d working area or run into wall"
  32.   end
  33.  
  34.   local s,r = turtle.forward()
  35.   if not s then
  36.     return false, r
  37.   end
  38.   if whereWall == 1 then
  39.     curWall = (curWall + 1) % 3
  40.     return true
  41.   elseif whereWall == 3 then
  42.     curWall = (curWall - 1) % 3
  43.     return true
  44.   end
  45. end
  46.  
  47. function goWall(wall)
  48.   if curWall ~= wall then
  49.     dist = wall - curWall
  50.     if dist > 0 and whereWall ~= 1 then
  51.       while whereWall ~= 1 do
  52.         if whereWall > 1 then
  53.           turnLeft()
  54.         else
  55.           turnRight()
  56.         end
  57.       end
  58.     elseif dist < 0 and whereWall ~= 3 then
  59.       while whereWall ~= 3 do
  60.         if whereWall < 1 then
  61.           turnLeft()
  62.         else
  63.           turnRight()
  64.         end
  65.       end
  66.     end
  67.     dist = math.abs(dist)
  68.     for i=1,dist do
  69.       forward()
  70.     end
  71.   end
  72. end
  73.  
  74. function cabinet()
  75.   goWall(2)
  76. end
  77.  
  78. cabinet()
  79.  
  80. while true do
  81.   local success, block = turtle.inspectDown()
  82.   addItemDown("farmersdelight:tomato_sauce",64)
  83. end
  84.  
  85.  
Advertisement
Add Comment
Please, Sign In to add comment