Advertisement
Guest User

build4

a guest
Nov 25th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.02 KB | None | 0 0
  1. local go = { ... }
  2. local height = 1
  3. local length1 = 0
  4. local length2 = 0
  5. local icount = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  6. local islot = 1
  7. local n = 0
  8. local x = 1
  9. local z = 1
  10. local y = 1
  11. local side = 1
  12. local dist = 0
  13. if #go == 1 then
  14.   length1 = tonumber(go[1])
  15.   length2 = tonumber(go[1])
  16. elseif #go == 2 then
  17.   length1 = tonumber(go[1])
  18.   length2 = tonumber(go[2])
  19. elseif #go == 3 then
  20.   length1 = tonumber(go[1])
  21.   length2 = tonumber(go[2])
  22.   height = tonumber(go[3])
  23. else
  24.   print ("Usage: length,width,height(optional)")
  25.   return
  26. end
  27. print("Length:",length1," Width:",length2," Height:",height)
  28. turtle.forward()
  29.  
  30. function buildlong()
  31.   dist = length1
  32.   moving()
  33. end
  34.  
  35. function buildwide()
  36.  if side == 4 then
  37.  print("side4")
  38.     dist = length2 - 1
  39.   else
  40.     dist = length2
  41.   end
  42.   moving()
  43. end
  44.  
  45. function moving()
  46. print("moving")
  47. if turtle.getItemCount(islot) ~= 0 then
  48.     turtle.placeDown()
  49.     dist = dist - 1
  50.  print(dist)
  51.     if dist == 0 then
  52.       if side ~= 4 then
  53.       turtle.turnRight()
  54.       else
  55.       turtle.forward()
  56.       turtle.turnRight()
  57.       end
  58.     side = side + 1
  59.         if (side == 2) or (side == 4) then
  60.         buildwide()
  61.         elseif side == 3 then
  62.         buildlong()
  63.         else
  64.           if y == height then
  65.           print("almost")
  66.           ENDit()
  67.          
  68.           else
  69.           side = 1
  70.           y = y + 1
  71.           turtle.up()
  72.           buildlong()
  73.          
  74.           end
  75.         end
  76.     else
  77.     end
  78.     turtle.forward()
  79.     moving()
  80.    
  81. else
  82. slotselect()
  83.  
  84. end
  85. end
  86.  
  87. function slotselect()
  88.   print("slotselect")
  89.   sleep(1)
  90.   islot = 1
  91.   while turtle.getItemCount(islot) == 0 do
  92.     while islot == 16 do
  93.         print("Press E to quit or C to continue.")  
  94.         local event, key = os.pullEvent("char") -- limit os.pullEvent to the 'key' event  
  95.         if key == keys.e then -- if the key pressed was 'e'
  96.             print("You pressed E. Ending...")
  97.             ENDit()
  98.                
  99.         elseif key == keys.c then
  100.             print("Moving On")
  101.             slotselect()
  102.                
  103.         else
  104.         end
  105.     end
  106.       islot = islot + 1
  107.   end
  108.   turtle.select(islot)
  109.   moving()
  110. end
  111.  
  112.  
  113. function ENDit()
  114. print("Done")
  115. os.reboot()
  116. end
  117.  
  118. buildlong()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement