Advertisement
Niseg

platform builder with cmd line arg

Feb 16th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. local turnLeft=true;
  2. local failCount=0;
  3. local breakFloor=true;
  4. local sel=0;
  5. local slot=1
  6. local width=1;
  7. local length=1;
  8. local args={...}
  9. print("ceiling builder by Niseg")
  10. print("refuel the turtle put tell it to go down 2 and start")
  11. turtle.select(slot)
  12. if #args==3 then
  13.     width=tonumber(args[1])
  14.     length=tonumber(args[2])
  15.     sel=tonumber(args[3])
  16.     if width<1 or length <1 then
  17.     print("invalid length or width")
  18.     exit()
  19.     end
  20. --  print("args3="+args[3])
  21.     if sel ~=1 and sel~=2 then
  22.         print("3rd arg invalid 1 right 2 left")
  23.         exit(1)
  24.     end
  25.    
  26. else
  27.  
  28.     repeat
  29.     print("width ")
  30.      
  31.     width=tonumber(read())
  32.     until width>0
  33.  
  34.  
  35.     repeat
  36.     print("length ")
  37.      
  38.     length=tonumber(read())
  39.     until length>0
  40.      
  41.      
  42.     repeat
  43.     print("build to  (1) right ")
  44.     print("built to  (2) left")
  45.      
  46.     sel=tonumber(read())
  47.     until sel==1 or sel==2
  48. end
  49. if(sel==1) then turnLeft=false end
  50.  
  51. for i= 1,width,1 do
  52.         for j= 1,length,1 do
  53.         if turtle.getItemCount(slot)==0 then
  54.                 slot=slot+1
  55.                 if slot <17 then
  56.                         turtle.select(slot)
  57.                 end
  58.         end
  59.         turtle.placeUp()
  60.         if j <length then turtle.forward() end
  61.  
  62. end
  63.                 if(turnLeft) then turtle.turnLeft()  else turtle.turnRight() end
  64.                 turtle.forward()
  65.                 if(turnLeft) then turtle.turnLeft()  else turtle.turnRight() end
  66.                 turnLeft = not turnLeft;
  67.                
  68.         end
  69. print("done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement