Shadow_Assailant

Shadow_Assailant's Dark Iron Forge

Jun 19th, 2013
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Shadow_Assailant's Dark Iron Forge--
  2. --v2.0--
  3.  
  4. local function checkInv(b) -- Searches for a slot with items and bypasses empty inventory slots
  5.   turtle.select(b)
  6.   if turtle.getItemCount(b)==0 then  
  7.     repeat  
  8.       b = b + 1
  9.       turtle.select(b)
  10.     until turtle.getItemCount(b)>0 or b==16
  11.   end
  12. end
  13.  
  14. local function transfering()
  15.   local z = 1
  16.   local l = turtle.getItemCount(16)
  17.   repeat
  18.     if turtle.getItemCount(z)<64 then
  19.       local s = turtle.getItemSpace(z)
  20.       turtle.select(16)
  21.       turtle.transferTo(z,s)
  22.       l = l - s
  23.       z = z + 1
  24.     else
  25.       z = z + 1
  26.     end
  27.   until l<=0
  28. end
  29.  
  30. local function wait(m)
  31.   m = m + 1
  32.   if m >= 10 then
  33.     term.clear()
  34.     term.setCursorPos(1,1)
  35.     print("Must let Wrath Fire regrow!")
  36.     print("Sleeping...")
  37.     sleep(90)
  38.     term.clear()
  39.     term.setCursorPos(1,1)
  40.     print("Resuming work!")    
  41.     term.setCursorPos(1,1)
  42.     m = 0
  43.   end
  44. end
  45.  
  46. for t = 1, 16 do
  47.   for f = 1, 15 do
  48.     while 2 > 1 do
  49.       term.clear()
  50.       term.setCursorPos(1,1)
  51.       local b = 1 -- So the above function defaults at 1      
  52.       local m = 0
  53.       local i = 0 -- Inventory 1 - 16
  54.       local q = 0 -- Inventory 1 - 15
  55.       i = turtle.getItemCount(t) -- Should(?) count items in each slot
  56.       q = turtle.getItemCount(f)
  57.       if i>0 then
  58.         term.setCursorPos(1,1)
  59.         print("Creating Dark Iron!")
  60.         term.setCursorPos(1,1)
  61.         if turtle.getItemCount(16)>0 and q>=897 then -- If the inventory is FULL of Iron, there needs to be space for the Dark Iron, so it creates 1 slot for space
  62.           turtle.select(16)
  63.           turtle.drop()
  64.           turtle.select(1)
  65.           i = i - turtle.getItemCount(16) -- Seeing as these blocks are gone, the count needs to be recaculated
  66.         elseif turtle.getItemCount(16)>0 and q<897 then
  67.           transfering()
  68.           turtle.select(1)
  69.         end
  70.         turtle.turnRight()
  71.         turtle.turnRight()
  72.         while i>0 and turtle.getItemCount(t)>0 do
  73.           checkInv(b)  
  74.           turtle.place()
  75.           sleep(3)
  76.           turtle.dig()
  77.           wait(m)
  78.           i = i - 1 -- One less block of regular iron, so must take that into account
  79.         end
  80.         turtle.turnRight()
  81.         turtle.turnRight()
  82.         turtle.select(t)
  83.         turtle.drop()
  84.         turtle.select(1)
  85.       else
  86.         term.clear()
  87.         sleep(1) -- Will wait until I give it iron
  88.        
  89.         print("Waiting!")
  90.         sleep(1)
  91.         term.setCursorPos(1,1)
  92.         i = turtle.getItemCount(t)
  93.         q = turtle.getItemCount(f)
  94.       end
  95.     end
  96.   end  
  97. end
Advertisement
Add Comment
Please, Sign In to add comment