Advertisement
Cookie042

quarry

Jun 8th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 KB | None | 0 0
  1. --args(depth, stepsX, stepsY, startDir, freshStart)
  2. args = {...}
  3. local numz = tonumber(args[1]) or 5
  4. local numx = tonumber(args[2]) or 1
  5. local numy = tonumber(args[3]) or numy
  6. local mon = peripheral.wrap("top")
  7.  
  8. dir = dir or nil
  9. --initial move dir (-1 == left) (1 == right)
  10. dir = tonumber(args[4]) or -1 --initial move dir
  11. local fresh = args[5] == "true" and true or false
  12. local ydir = "f" --row step dir
  13.  
  14. local sizex, sizey = 5, 5
  15. local lastmove = ydir
  16. local ddep = 27
  17.  
  18. function deploy(a1,a2,a3)
  19.     shell.run("deploy",a1,a2,a3)
  20. end
  21.  
  22. function printPos(x,y,z)
  23.   mon.clearLine()
  24.   local cx, cy = mon.getCursorPos()
  25.   mon.setCursorPos(1,cy)
  26.   mon.write(tostring(x)..","..tostring(y)..","..tostring(z).." of "..tostring(numx)..","..tostring(numy)..","..tostring(numz))
  27. end
  28.  
  29. --deploy("r")
  30.  
  31. for y=1,numy do
  32.   for x=1,numx-1 do
  33.     for z=1,numz do
  34.       shell.run("dig")   
  35.       --when past threshold deploy
  36.       if z>ddep then
  37.         sleep(.2)
  38.         --deploy logic
  39.         if (y == 1)(
  40.           if fresh then
  41.             if elseif lastmove == "l" then
  42.                 deploy(ydir,"l","b")
  43.             elseif lastmove == "r" then
  44.                 deploy(ydir,"r","b")
  45.             else lastmove == ydir then
  46.                 deploy() -- all sides
  47.             end
  48.           else       
  49.             if lastmove == ydir then deploy(ydir,"l","r")
  50.             elseif lastmove == "l" then deploy(ydir,"l")
  51.             elseif lastmove == "r" then deploy(ydir,"r")
  52.           else deploy()
  53.         end
  54.       end
  55.       shell.run("move","ad","1")     
  56.       printPos(x,y,z) --update display every movement
  57.     end --z
  58.     --retract
  59.     shell.run("move","au",tostring(numz))
  60.   end --x
  61.   if dir>0 then lastmove = "r" else lastmove = "l" end
  62.   shell.run("move",lastmove,sizey)
  63.   fresh = false
  64.  
  65.   dir = -dir
  66.   lastmove = ydir
  67.   shell.run("move",lastmove,sizex)
  68.   print()
  69. end --y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement