Advertisement
Redxone

Deh Turtle Cat AI

Jul 20th, 2015
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. --]] Turtle Cat AI By: Redxone [[--
  2.  
  3. --]] First, lets make a movement table [[--
  4. local movements = {
  5.    
  6.     turtle.forward,
  7.     turtle.back,
  8.     turtle.turnLeft,
  9.     turtle.turnRight,
  10. }
  11.  
  12. local exceptions = {
  13.    
  14.     "minecraft:stone_brick_stairs",
  15.     "minecraft:oak_stairs",
  16.     "minecraft:stone_stairs",
  17.     "minecraft:brick_stairs",
  18.     "minecraft:red_sandstone_stairs",
  19.     "minecraft:nether_brick_stairs",
  20.     "minecraft:sandstone_stairs",
  21.     "minecraft:spruce_stairs",
  22.     "minecraft:birch_stairs",
  23.     "minecraft:jungle_stairs",
  24.     "minecraft:quartz_stairs",
  25.     "minecraft:acacia_stairs",
  26.     "minecraft:dark_oak_stairs",
  27.  
  28. }
  29.  
  30. --]] usefull functions [[--
  31.  
  32. function move()
  33.     local dir = math.random(1,#movements)
  34.  
  35.  
  36.     bl = {turtle.inspect()}
  37.     local ex = false
  38.  
  39.     if(bl[1])then
  40.         for i=1, #exceptions do
  41.             if(bl[2] == exceptions[i])then
  42.                 ex=true
  43.                 turtle.up()
  44.                 turtle.forward()
  45.             end
  46.         end
  47.     end
  48.  
  49.     if(not ex and turtle.detect())then
  50.         turtle.turnLeft()
  51.         turtle.turnLeft()
  52.         turtle.forward()
  53.     end
  54.  
  55.         if(not turtle.detectUp() and turtle.detectDown() and ex)then
  56.             turtle.up()
  57.         else
  58.             if(not turtle.detectDown())then turtle.down() end
  59.         end
  60.     if(turtle.detectDown() and not ex)then movements[dir]() end
  61.     sleep(math.random(0.05,0.3))
  62. end
  63.  
  64. function brain()
  65.     while true do
  66.         sleep(0.05)
  67.         move()
  68.     end
  69. end
  70. brain()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement