Advertisement
hyndgrinder

Flooring

May 19th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.70 KB | None | 0 0
  1. p=peripheral.wrap("right")
  2. if p then
  3. print (true)
  4. end
  5.  
  6. print ("How many steps?")
  7. local steps=tonumber(read())
  8. print ("How many blocks wide?")
  9. width=tonumber(read())
  10. print ("How tall should it be?")
  11. local strY=read()
  12. local y=tonumber(strY)
  13. if y<=2 then
  14.      y=nil
  15. else
  16.      y=y-1
  17. end
  18. print ("Do I change the floor?")
  19. if read() =="y" then
  20.     print ("What slot are the flooring tiles in?")
  21.     nSlot=tonumber(read())
  22.     bFloor=true
  23. end
  24. print ("Do I change the roof?")
  25. if read() =="y" then
  26.     print ("What slot are the roof tiles in?")
  27.     rSlot=tonumber(read())
  28.     bRoof=true
  29. end
  30.  
  31. print ("Should I build walls? y/n")
  32. if read()=="y" then
  33.     bWalls=true
  34.     print("What slot are the wall tiles in?")
  35.     wSlot=tonumber(read())
  36. else
  37.     bWalls=false
  38. end
  39.  
  40. local amt=turtle.getItemCount(nSlot)
  41. lat=0
  42.  
  43. ------------Compare Wall Block-------
  44. function wComp()
  45.     if turtle.compare()~=true then
  46.         turtle.dig()
  47.         turtle.place()
  48.     end
  49. end
  50.  
  51.  
  52. ------------digWall------------
  53. function digWall()
  54.     if (lat==0 or lat==width-1) and bWalls==true then
  55.         turtle.select(wSlot)
  56.         if lat~=0 and lat%2==0 then
  57.             turtle.turnRight()
  58.             wComp()
  59.             turtle.turnLeft()
  60.         else
  61.             turtle.turnLeft()
  62.             wComp()
  63.             turtle.turnRight()
  64.         end    
  65.     end
  66. end
  67.  
  68. -------Turtle Forward With Dig-----
  69.  
  70. function digNmove(y,rSlot)
  71.     print ("height: ", y)
  72.     digWall()
  73.     if y then
  74.         for i=1, y do
  75.             while turtle.detectUp()==true do
  76.                 turtle.digUp()
  77.             end
  78.             shell.run("go" , "up", 1)
  79.             digWall()
  80.             if i==y and bRoof==true then
  81.                 turtle.select(rSlot)
  82.                 turtle.digUp()
  83.                 turtle.placeUp()
  84.             end
  85.         end
  86.         shell.run("go", "down", y)
  87.     end
  88.     while turtle.detect() do
  89.         turtle.dig()
  90.     end
  91.     shell.run("go", "forward", 1)
  92. end
  93.  
  94.  
  95. ----Go Steps----
  96. function goSteps(nSlot)
  97. p.condenseItems()
  98. local i=1
  99.     while i<=steps  and bFloor==true do
  100.         if turtle.detectDown()== true then
  101.             turtle.digDown()
  102.         end
  103.         local amt=turtle.getItemCount(nSlot)
  104.         if amt<1 then
  105.             print ("Out of materials in ", nSlot, ".\n  Refill, and press any key!")
  106.             read()
  107.         end
  108.         turtle.select(nSlot)
  109.         turtle.placeDown()
  110.        
  111.         if i<steps then
  112.             digNmove(y,rSlot)
  113.         end
  114.         i=i+1
  115.     end
  116.    
  117. end
  118.  
  119. -----------Get TurnDir--------
  120. function turnDir(lat)
  121. print ("turning for lat", lat)
  122.  
  123. --if lat==0 then
  124. local _mod=lat%2
  125. --[[else
  126. local _mod=math.modf(lat)
  127. end--]]
  128.  
  129. print ("Mod: ",_mod)
  130.     if _mod==0 then
  131.         turtle.turnRight()
  132.         print ("right")
  133.     else
  134.         turtle.turnLeft()
  135.         print("left")
  136.     end
  137. end
  138.  
  139. ----------------PROCESS----------
  140. while lat<width do
  141.     goSteps(nSlot)
  142.    
  143.  
  144. turnDir(lat)
  145. digNmove(y, rSlot)
  146. turnDir(lat)
  147.  
  148. lat=lat+1
  149. sleep(0.2)
  150. end
  151. print("finished")
  152. bFloor=nil
  153. bRoof=nil
  154. bWalls=nil
  155. wSlot=nil
  156. width=nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement