Advertisement
Guest User

dig

a guest
May 4th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. local r=require("robot")
  2. local c=require("component")
  3.  
  4. print(r.level())
  5.  
  6. l = 8
  7. w = 5
  8. h = 1
  9. dir = "1up"
  10. t=1
  11. floor = 0
  12.  
  13. function cut()
  14.  
  15.   while r.detectDown() do
  16.     r.swingDown()
  17.     if r.detectDown() then
  18.       r.select(16)
  19.       c.inventory_controller.equip()
  20.       r.swingDown()
  21.       c.inventory_controller.equip()
  22.     end    
  23.   end
  24.  
  25.   while r.detect() do
  26.     r.swing()
  27.     if r.detect() then
  28.       r.select(16)
  29.       c.inventory_controller.equip()
  30.       r.swing()
  31.       c.inventory_controller.equip()
  32.     end    
  33.   end
  34.  
  35.   while r.detectUp() do
  36.     r.swingUp()
  37.     if r.detectUp() then
  38.       r.select(16)
  39.       c.inventory_controller.equip()
  40.       r.swingUp()
  41.       c.inventory_controller.equip()
  42.     end    
  43.   end
  44. end
  45.  
  46. for k = 1, h do
  47.   for j = 1 , w do
  48.     for i = 1, l-1 do
  49.       cut()
  50.       r.forward()
  51.     end
  52.  
  53.     if j<w then
  54.     if t==-1 then
  55.       r.turnLeft()
  56.       cut()
  57.       r.forward()
  58.       r.turnLeft()
  59.     else  
  60.       r.turnRight()
  61.       cut()
  62.       r.forward()
  63.       r.turnRight()
  64.     end
  65.     else
  66.       r.turnAround()
  67.       cut()
  68.     end
  69.     t=-t
  70.   end
  71.   t=-t
  72.  
  73. if k<h then  
  74.   if dir == "up" then
  75.     cut()
  76.     r.up()
  77.     cut()
  78.     r.up()
  79.     cut()
  80.     r.up()
  81.     if floor == 1 then
  82.       cut()
  83.       r.up()
  84.     end
  85.   else
  86.     cut()
  87.     r.down()  
  88.     cut()
  89.     r.down()
  90.     cut()
  91.     r.down()
  92.     if floor == 1 then
  93.       cut()
  94.       r.down()
  95.     end
  96.   end
  97. end
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement