Advertisement
Guest User

go.lua

a guest
Apr 3rd, 2020
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. local colors = {1, 5, nil, nil,
  2.  6, nil, nil, 3,
  3.  2, nil, nil, nil,
  4.  nil, nil, 0, 4}
  5. --colors[a+1]
  6. local waitingRotate = false
  7. local numberOfAction = nil
  8.  
  9. local function emptyFunction()
  10. end
  11. local function choose1()
  12.     return turtle.turnLeft 
  13. end
  14. local function choose2()
  15.     return turtle.turnRight
  16. end
  17. local function choose3()
  18.     a = math.random(2)
  19.     if (a == 1) then return emptyFunction
  20.     else return turtle.turnLeft
  21.     end
  22. end
  23. local function choose4()
  24.     a = math.random(2)
  25.     if (a == 1) then return emptyFunction
  26.     else return turtle.turnRight
  27.     end
  28. end
  29. local function choose5()
  30.     a = math.random(2)
  31.     if (a == 1) then return turtle.turnLeft
  32.     else return turtle.turnRight
  33.     end
  34. end
  35. local actions = {choose1, choose2, choose3, choose4, choose5}
  36.  
  37. while true do
  38.     _, block = turtle.inspectDown()
  39.     if (block.name == "minecraft:wool") then
  40.         action = colors[block.metadata + 1]
  41.     else action = nil;
  42.     end
  43.     if (action ~= nil) then
  44.         if (action == 0) then
  45.             write("Let`s go "..tostring(action).."\n")
  46.             if (a ~= nil) then             
  47.                 a()()  
  48.             end
  49.             waitingRotate = false;
  50.         elseif (action >= 1 and action <=5) then
  51.             write("I need to go deeper "..tostring(action).."\n")
  52.             a = actions[action]
  53.             waitingRotate = true
  54.         elseif (action == 6) then
  55.             write("I need rotate "..tostring(action).."\n")
  56.             turtle.turnLeft()
  57.             turtle.turnLeft()
  58.         end
  59.     end
  60.     if (action == nil) then
  61.         waitingRotate = false
  62.     end
  63.     turtle.forward();
  64.     --sleep(1)
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement