Niseg

advanced room builder 2 (old version)

Apr 30th, 2013
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     local count=0
  2.     local slot =1    
  3. local function ensureSlot()
  4.     if count==0 then
  5.     slot=slot+1;
  6.     count=turtle.getItemCount(slot)
  7.     if count==0 then exit() end
  8.     turtle.select(slot)
  9.     end
  10.     end
  11.      
  12.     count=turtle.getItemCount(slot)
  13. local function buildWall(x,y,z)
  14.    
  15.     local zr=0;
  16.    
  17.     zr=z %3
  18.     z=math.floor(z/3)
  19.     if (zr~=0) then z=z+1 end
  20.     local buildUp=true;
  21.     local buildForward=true;
  22.     for k=1,z do
  23.     if(k<z) then buildUp=true;buildForward=true;
  24.     elseif zr==1 then   buildUp=false;buildForward=false;
  25.     elseif zr==2 then   buildUp=false;buildForward=true;
  26.     else                buildUp=true ;buildForward=true;
  27.     end
  28.    
  29.    
  30.     turtle.up()
  31.    
  32.     for j=1,2 do
  33.             for i=1,x-2 do
  34.                     turtle.placeDown()
  35.                     count=count-1;ensureSlot()
  36.                     if buildUp then
  37.                     turtle.placeUp()
  38.                     count=count-1;ensureSlot()
  39.                     end
  40.                     turtle.back()
  41.                     if buildForward then
  42.                     turtle.place()
  43.                     count=count-1;ensureSlot()
  44.                     end
  45.             end
  46.             turtle.placeDown()
  47.             count=count-1;ensureSlot()
  48.             if buildUp then
  49.                 turtle.placeUp()
  50.                 count=count-1;ensureSlot()
  51.             end
  52.             turtle.turnLeft()
  53.             turtle.back()
  54.             if buildForward  then
  55.                 turtle.place()
  56.                count=count-1;ensureSlot()
  57.             end
  58.      
  59.             for i=1,y-2 do
  60.                     turtle.placeDown()
  61.                     count=count-1;ensureSlot()
  62.                     if buildUp then
  63.                     turtle.placeUp()
  64.                     count=count-1;ensureSlot()
  65.                     end
  66.                     turtle.back()
  67.                     if buildForward then
  68.                     turtle.place()
  69.                     count=count-1;ensureSlot()
  70.                     end
  71.             end
  72.             turtle.placeDown()
  73.             count=count-1;ensureSlot()
  74.             if buildForward and j==2 then
  75.                     turtle.up()
  76.                     turtle.placeDown()
  77.                     count=count-1;ensureSlot()
  78.             end
  79.             if buildUp then
  80.                 if j==1 then
  81.                     turtle.placeUp()
  82.                     count=count-1;ensureSlot()
  83.                 else
  84.                     turtle.up()
  85.                     turtle.placeDown()
  86.                     count=count-1;ensureSlot()
  87.                 end
  88.             end
  89.                
  90.             turtle.turnLeft()
  91.             turtle.back()
  92.             if buildForward and j==1 then
  93.                 turtle.place()
  94.                count=count-1;ensureSlot()
  95.             end
  96.      
  97.     end
  98.     end
  99.    
  100.     turtle.forward()
  101.     end
  102.     local function buildPlate(x,y)
  103.     turtle.up()
  104.     for j=1,y do
  105.         for i=1,x-1 do
  106.        
  107.             turtle.placeDown()
  108.             count=count-1;ensureSlot()
  109.                turtle.back()
  110.         end
  111.             turtle.placeDown()
  112.             count=count-1;ensureSlot()
  113.             if(j<y) then
  114.             if(j%2== 1) then turtle.turnLeft() else turtle.turnRight() end
  115.             turtle.back()
  116.            
  117.             if(j%2== 1) then turtle.turnLeft() else turtle.turnRight() end
  118.             end
  119.             --turtle.back()
  120.    
  121.     end
  122.     end
  123.    
  124.     print("make sure the turtle is refueld ")
  125.     print("load building material in all slots")
  126.     print(" place turtle at bottom right corner (builds in place)")
  127.     print("first wall?")
  128.     local x1=tonumber(read())
  129.     print("second wall?")
  130.     local y1=tonumber(read())
  131.     print("height?")
  132.     local z1=tonumber(read())
  133.     local sel=0
  134. turtle.select(1)
  135.     repeat  
  136.     print("0= walls 1 = add floor ,2 = add roof 3= add both" )
  137.     sel=tonumber(read())
  138.     until(sel>=0 and sel<=3)
  139.     turtle.turnRight();turtle.turnRight();
  140.     if((sel==1 or sel==3) and z1>0) then
  141.         buildPlate(x1,y1);
  142.         z1=z1-1;
  143.         if(y1%2==1) then
  144.         turtle.turnRight();turtle.turnRight();
  145.         else
  146.         turtle.turnLeft();
  147.         end
  148.     end
  149.     turtle.back()
  150.     if ((sel==2 or sel==3 )and z1>1) then
  151.     buildWall(x1,y1,z1-1)
  152.     buildPlate(x1,y1)
  153.     else
  154.     if(z1>0) then buildWall(x1,y1,z1) end
  155.     end
  156.      
  157.     --if(zr~=0) then z=z-1; end
  158.     --z=z*3+zr
  159.     --for i=1,z do turtle.down() end
Advertisement
Add Comment
Please, Sign In to add comment