Advertisement
punchin

CC_EnderEnder

Feb 1st, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.73 KB | None | 0 0
  1. local args = {...}
  2. local width = 0 -- Width of EnderEnder spawning layers
  3. local pads = 0 -- Number of spawning layers
  4. local x = 0 -- Local GPS Coordinates
  5. local y = 0
  6. local z = 0
  7. local d = 0 -- Direction Facing
  8. local xx,yy,zz,dd = 0 -- Backup Coordinates
  9. local chestD = 4 -- Direction Supply Chest is in
  10. local invTotal = 0 -- Total blocks in inventory matching slot 1
  11.  
  12. local function cls(a,b) -- Clear Screen and variable positioning
  13.     if not a then a = 1 end
  14.     if not b then b = 1 end
  15.     term.clear()
  16.     term.setCursorPos(a,b)
  17. end
  18.  
  19. -- Syntax Check --
  20. cls()
  21. --print(args[1] .. "," .. args[2])
  22. --read()
  23. if args[1] then
  24.     if args[2] then
  25.         width = args[1]
  26.         pads = args[2]
  27.     else
  28.         print("Usage: EnderEnder [width, pads]")
  29.     end
  30. else
  31.     print("Enter desired width:")
  32.     width = read()
  33.     print("How many spawning layers?")
  34.     print("(4 blocks per layer):")
  35.     pads = read()
  36. end
  37.  
  38. -- Fuel Check --
  39. local function fuel()
  40.     if not (turtle.getFuelLevel() == "infinite") then
  41.         if turtle.getFuelLevel() == 0 then
  42.             while not turtle.refuel(1) do
  43.                 cls()
  44.                 print("Out of fuel! Please add more fuel!")
  45.                 for i=1,4 do turtle.turnRight() end
  46.             end
  47.         end
  48.     end
  49. end
  50.  
  51. -- GPS --
  52. local function GPS(val)
  53.     if (val == 1) then
  54.         if (d == 0) then z = z + 1
  55.         elseif (d == 1) then x = x + 1
  56.         elseif (d == 2) then z = z - 1
  57.         elseif (d == 3) then x = x - 1
  58.         end
  59.     elseif (val == 2) then
  60.         d = d + 1
  61.         if (d == 4) then d = 0 end
  62.     elseif (val == 3) then
  63.         d = d - 1
  64.         if (d == -1) then d = 3 end
  65.     end
  66.     --print("X:" .. x .. ", Y:" .. y ..  ", Z:" .. z .. ", D:" .. d)
  67. end
  68.  
  69. -- Inventory Manager --
  70. local function countInv()
  71.     invTotal = 0
  72.     for i=16,1,-1 do
  73.         if (turtle.getItemCount(i) > 0) then
  74.             turtle.select(i)
  75.             if turtle.compareTo(1) then
  76.                 invTotal = invTotal + turtle.getItemCount(i)
  77.             end
  78.         end
  79.     end
  80.     turtle.select(1)
  81. end
  82.  
  83. local function inv()
  84.     if (turtle.getItemCount(1) <= 1) then
  85.         countInv()
  86.         if (invTotal <= 1) then
  87.             while (invTotal <= 1) do
  88.                 for s=1,4 do tr() end
  89.                 cls() print("Out of items! Please add more items!")
  90.                 countInv()
  91.             end
  92.         else
  93.             for s=2,16 do
  94.                 if (turtle.getItemCount(s) > 0) then
  95.                     turtle.select(s)
  96.                     turtle.transferTo(1)
  97.                 end
  98.             end
  99.         end
  100.     end        
  101.     turtle.select(1)
  102. end
  103.  
  104. -- Movement Functions --
  105.  
  106. local function mf() while not turtle.forward() do turtle.attack() turtle.dig() end GPS(1) fuel() end
  107. local function mu() while not turtle.up() do turtle.attackUp() turtle.digUp() end y = y + 1 fuel() end
  108. local function md() while not turtle.down() do turtle.attackDown() turtle.digDown() end y = y - 1 fuel() end
  109. local function tr() turtle.turnRight() GPS(2) end
  110. local function tl() turtle.turnLeft() GPS(3) end
  111. local function pu() if turtle.detectUp() then turtle.digUp() end turtle.placeUp() inv() end
  112. local function pf() if turtle.detect() then turtle.dig() end turtle.place() inv() end
  113. local function pd() if turtle.detectDown() then turtle.digDown() end turtle.placeDown() inv() end
  114.  
  115. -- Block Check --
  116. for i=1,4 do
  117.     tr()
  118.     if (chestD == 4) then
  119.         if turtle.suck(1) then
  120.             chestD = d
  121.             cls()
  122.             print("Found chest in direction " .. chestD .. ".")
  123.             --turtle.drop(1)
  124.             while turtle.suck() do end
  125.         end
  126.     end
  127. end
  128.  
  129. if (chestD == 4) then
  130.     cls()
  131.     print("Please place a chest with extra building materials next to the turtle.")
  132.     return
  133. end
  134.  
  135. if (chestD == 0) then
  136.     cls()
  137.     print("Please move chest from in front of turtle or rotate turtle.")
  138.     return
  139. end
  140.  
  141. -- Placement Check --
  142. cls()
  143. print("Turtle will build to the right.")
  144. print("Please press [enter] if turtle is placed correctly,")
  145. print("or hold [Ctrl+T] to cancel and reposition.")
  146. read()
  147.  
  148. -- Build Landing Pad and Falling Chute --
  149. fuel()
  150. mf() tr() mu()
  151. pd() for m=1,width do mf() pd() end -- Landing Pad
  152. mf() pd() mu() pd() mu() pd() tr() tr() pu() mf() tr() tr() pf() tr() tr() -- RH Pillar
  153.  
  154. for r=1,12 do -- 13 "Ribs" on the Falling Chute
  155.     for m=1,width do tr() pf() tl() tl() pf() tr() mf() end -- Building the Ribs
  156.     pd() mu() pd() mu() pd() mu() pd() tr() tr() pu() mf() tr() tr() pf() tr() tr() -- Moving to the Next Rib
  157. end
  158.  
  159. for r=1,3 do -- "Fall Brake" to standardize fall damage
  160.     for m=1,width do tr() pf() tl() tl() pf() tr() mf() end -- Building the walls
  161.     pd() mu() pd() tr() tr() pu() mf() tr() tr() pf() tr() tr() -- Moving to the Next Wall
  162. end
  163.  
  164. tl() mu() mf() tl() mf() tl()
  165.  
  166. for r=1,pads do -- Spawning Pads
  167.     mf() pu() mf() pu() mf() tl() mu()
  168.     for b=1,width do mf() pd() end
  169.     mf() md() tl() mf() pu() mf() pu() mf() pu() mf() mu() tl()
  170.     for b=1,width do mf() pd() end
  171.     mf() tl() pf() -- Finished redstone/tripwire ring
  172.     mu() mu() mf()
  173.     for h=1,2 do -- Spawning Rings
  174.         for b=1,2 do
  175.             pd() mf()
  176.         end
  177.         tl()
  178.         for b=1,width+1 do
  179.             pd() mf()
  180.         end
  181.         tl()
  182.     end
  183.     mu()
  184. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement