Guest User

wip1

a guest
Jun 19th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.36 KB | None | 0 0
  1. -- Construction Definitions ###################################
  2. -- Profiles (individual collums)
  3. pro1 = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
  4. pro2 = {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
  5. pro3 = {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1}
  6. pro4 = {0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1}
  7. pro5 = {0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1}
  8. pro6 = {0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1}
  9. pro7 = {0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1}
  10. pro8 = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  11. -- Planes (sets of collums to create planes)
  12. pla1 = {2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} -- basic platform
  13. pla2 = {8,2,3,3,3,3,3,3,3,3,3,3,3,3,3,2} -- Open room
  14. pla3 = {8,2,6,6,6,6,6,6,6,6,6,6,6,6,6,2} -- x-axis split room
  15. pla4 = {8,2,3,3,3,3,3,3,2,3,3,3,3,3,3,2} -- z-axis split room
  16. pla5 = {8,2,6,6,6,6,6,6,7,6,6,6,6,6,6,2} -- -z tri-split room
  17. pla6 = {8,2,3,3,3,4,5,5,3,5,5,4,3,3,3,2} -- ctrl-room layer 1
  18. pla7 = {8,2,3,3,3,4,5,3,3,3,5,4,3,3,3,2} -- ctrl-room layer 2,3
  19. pla8 = {8,2,3,3,3,5,5,5,5,5,5,5,3,3,3,2} -- ctrl-room layer 4,5
  20. -- Rooms (sets of planes)
  21. roo1 = {1} -- floor
  22. roo2 = {2,2,2,1} -- basement (3block clearence)
  23. roo3 = {2,2,2,2,2,1} --
  24. roo3 = {6,7,7,8,8,1} -- control room (5block clearence)
  25. roo4 = {2,2,2,2,2,1} -- open room
  26. roo5 = {3,3,3,3,3,1} -- x-split room
  27. roo6 = {4,4,4,4,4,1} -- z-split room
  28. roo7 = {5,5,5,5,5,1} -- -z tri-split room
  29. -- Initial System Variables ###################
  30. local elev = 0
  31. local xPos,zPos = 0,0
  32. local xDir,zDir = 0,1
  33. local selSlot = 1
  34. turtle.select(1)
  35. local iCount = nil
  36. -- Movement Functions #########################
  37. function turnRight()
  38.   turtle.turnRight()
  39.   xDir, zDir = zDir, -xDir
  40. end
  41. function turnLeft()
  42.   turtle.turnLeft()
  43.   xDir, zDir = -zDir, xDir
  44. end
  45.  
  46. function goHome()
  47.   if zPos > 0 then
  48.     while zDir ~= -1 do
  49.      turnRight()
  50.     end
  51.     while zPos > 0 do
  52.      advance()
  53.     end
  54.   end
  55.   if xPos > 0 then
  56.     while xDir ~= -1 do
  57.      turnRight()
  58.     end
  59.     while xPos > 0 do
  60.      advance()
  61.     end
  62.   end
  63.   -- elevation handeler -- tba
  64.   while zDir ~= 1 do
  65.     turnRight()
  66.   end
  67. end
  68. -- Turtle Maintance functions ##############################
  69. --function resupply()
  70. --   local x,y,z,xd,zd = xPos,elev,zPos,xDir,zDir
  71. --   goTo(0,0,0,0,-1)
  72. --end
  73.  
  74. -- Core construction functions #############################
  75.  
  76. function advance()
  77.   turtle.forward()
  78.   xPos = xPos + xDir
  79.   zPos = zPos + zDir
  80. end
  81.  
  82. function buildFwd()
  83.   icount = turtle.getItemCount(selSlot)
  84.   if icount < 1 then
  85.     selSlot = selSlot + 1
  86.     turtle.select(selSlot)
  87.   end
  88.   turtle.placeDown()
  89.   advance()
  90. end
  91.  
  92. function turnAround()
  93.   if zDir == 1 then
  94.     turnRight()
  95.     advance()
  96.     turnRight()
  97.     advance()
  98.   else
  99.     turnLeft()
  100.     advance()
  101.     turnLeft()
  102.     advance()
  103.   end
  104. end
  105. -- ############################################
  106. function advOrBuild(x)
  107.   if x == 1 then
  108.     buildFwd()
  109.   else
  110.     advance()
  111.   end
  112. end
  113.  
  114. function layColumn(num)
  115.   if zDir == 1 then
  116.     b=1
  117.     c=16
  118.     d=1
  119.    elseif zDir == -1 then
  120.     b=16
  121.     c=1
  122.     d=-1
  123.   end
  124.  
  125.   for a = b, c, d do
  126.     if num == 1 then
  127.       advOrBuild(pro1[a])
  128.     elseif num == 2 then
  129.       advOrBuild(pro2[a])
  130.     elseif num == 3 then
  131.       advOrBuild(pro3[a])
  132.     elseif num == 4 then
  133.       advOrBuild(pro4[a])
  134.     elseif num == 5 then
  135.       advOrBuild(pro5[a])
  136.     elseif num == 6 then
  137.       advOrBuild(pro6[a])
  138.     elseif num == 7 then
  139.       advOrBuild(pro7[a])
  140.     elseif num == 8 then
  141.       advOrBuild(pro8[a])
  142.     end
  143.   end
  144. end
  145.  
  146. function layPlane(num)
  147.   if num == 1 then
  148.     for a = 1, #pla1 do
  149.       layColumn(pla1[a])
  150.       turnAround()
  151.     end
  152.   elseif num == 2 then
  153.     for a = 1, #pla2 do
  154.       layColumn(pla2[a])
  155.       turnAround()
  156.     end
  157.   elseif num == 3 then
  158.     for a = 1, #pla3 do
  159.       layColumn(pla3[a])
  160.       turnAround()
  161.     end
  162.   elseif num == 4 then
  163.     for a = 1, #pla4 do
  164.       layColumn(pla4[a])
  165.       turnAround()
  166.     end
  167.   elseif num == 5 then
  168.     for a = 1, #pla5 do
  169.       layColumn(pla5[a])
  170.       turnAround()
  171.     end
  172.   elseif num == 6 then
  173.     for a = 1, #pla6 do
  174.       layColumn(pla6[a])
  175.       turnAround()
  176.     end
  177.   elseif num == 7 then
  178.     for a = 1, #pla7 do
  179.       layColumn(pla7[a])
  180.       turnAround()
  181.     end
  182.   elseif num == 8 then
  183.     for a = 1, #pla8 do
  184.       layColumn(pla8[a])
  185.       turnAround()
  186.     end
  187.   end
  188.   goHome()
  189.   turtle.up()
  190. end  
  191. -- Program Proper ##############
  192. layPlane(1)
  193. layPlane(2)
  194. layPlane(2)
  195. layPlane(2)
  196. layPlane(1)
  197. layPlane(6)
  198. layPlane(7)
  199. layPlane(7)
  200. layPlane(8)
  201. layPlane(8)
  202. layPlane(1)
Advertisement
Add Comment
Please, Sign In to add comment