Advertisement
hyndgrinder

mkRoom

May 12th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.68 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. nSlot=0
  14. if y<=2 then
  15.      y=nil
  16. else
  17.      y=y-1
  18. end
  19. print ("Do I change the floor?")
  20. if read() =="y" then
  21.     print ("What slot are the flooring tiles in?")
  22.     nSlot=tonumber(read())
  23.     bFloor=true
  24. end
  25. print ("Do I change the roof?")
  26. if read() =="y" then
  27.     print ("What slot are the roof tiles in?")
  28.     rSlot=tonumber(read())
  29.     bRoof=true
  30. end
  31.  
  32. print ("Should I build walls? y/n")
  33. if read()=="y" then
  34.     bWalls=true
  35.     print("What slot are the wall tiles in?")
  36.     wSlot=tonumber(read())
  37. else
  38.     bWalls=false
  39. end
  40.  
  41. local amt=turtle.getItemCount(nSlot)
  42. lat=0
  43.  
  44. ------------Compare Wall Block-------
  45. function wComp()
  46.     if turtle.compare()~=true then
  47.         turtle.dig()
  48.         turtle.place()
  49.     end
  50. end
  51.  
  52.  
  53. ------------digWall------------
  54. function digWall()
  55.     if (lat==0 or lat==width-1) and bWalls==true then
  56.         turtle.select(wSlot)
  57.         if lat~=0 and lat%2==0 then
  58.             turtle.turnRight()
  59.             wComp()
  60.             turtle.turnLeft()
  61.         else
  62.             turtle.turnLeft()
  63.             wComp()
  64.             turtle.turnRight()
  65.         end    
  66.     end
  67. end
  68.  
  69. -------Turtle Forward With Dig-----
  70.  
  71. function digNmove(y,rSlot)
  72.     print ("height: ", y)
  73.     digWall()
  74.     if y then
  75.         for i=1, y do
  76.             while turtle.detectUp()==true do
  77.                 turtle.digUp()
  78.             end
  79.             shell.run("go" , "up", 1)
  80.             digWall()
  81.             if i==y and bRoof==true then
  82.                 turtle.select(rSlot)
  83.                 turtle.digUp()
  84.                 turtle.placeUp()
  85.             end
  86.         end
  87.         shell.run("go", "down", y)
  88.     end
  89.     while turtle.detect() do
  90.         turtle.dig()
  91.     end
  92.     shell.run("go", "forward", 1)
  93. end
  94.  
  95.  
  96. ----Go Steps----
  97. function goSteps(nSlot)
  98. p.condenseItems()
  99. local i=1
  100.     while i<=steps  do
  101.         if turtle.detectDown()== true and bFloor==true then
  102.             turtle.digDown()
  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.         end
  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