View difference between Paste ID: pGQ1vTBR and wzxEU2Wk
SHOW: | | - or go back to the newest paste.
1
--Shadow_Assailant's Dark Iron Forge--
2-
--v3.0--
2+
--v4.0--
3
4-
local function checkInv() -- Searches for a slot with items and bypasses empty inventory slots
4+
local function transfering() -- Transfers items to slot 1
5-
  turtle.select(b)
5+
6-
  if turtle.getItemCount(b)==0 then  
6+
    turtle.select(f)
7-
    repeat  
7+
    turtle.transferTo(1,turtle.getItemSpace(1))
8-
      b = b + 1
8+
    turtle.select(16)
9-
      turtle.select(b)
9+
    turtle.transferTo(1,turtle.getItemSpace(1))
10-
    until turtle.getItemCount(b)>0
10+
11
  turtle.select(1)
12
end
13
14-
local function transfering()
14+
local function wait() -- Wrath Flame dies if used too much. A pause is needed to let it grow.
15-
  local l = turtle.getItemCount(16)
15+
16-
  repeat
16+
  if m >= 10 then -- Not sure how many uses kills the flame, but this should be enough.
17-
    if turtle.getItemCount(z)<64 then
17+
18-
      local s = turtle.getItemSpace(z)
18+
19
    print("Must let Wrath Fire regrow!")
20-
      turtle.transferTo(z,s)
20+
21-
      l = l - s
21+
    sleep(90) -- Not sure how long it takes the flame to revitalize.
22-
      z = z + 1
22+
23-
    else
23+
24-
      z = z + 1
24+
25
    term.setCursorPos(1,1)
26-
  until l<=0
26+
27
  end
28
end
29-
local function wait()
29+
30
local function holdingAnything() -- Instantaneous check to see if anything at all is in the turtle's inventory.
31-
  if m >= 10 then
31+
  for i=1,16 do
32
    if turtle.getItemCount(i) > 0 then
33
      return true
34
    end
35
  end
36-
    sleep(90)
36+
  return false
37
end
38
  
39
while true do
40
  q=0 -- Defaults inventory count to 0
41
  m=0 -- Defaults blocks broken to 0
42
  term.clear()
43
  term.setCursorPos(1,1)
44-
 
44+
  if holdingAnything()==true then
45
    for f = 1, 15 do
46-
  b = 1
46+
      q = 0 + turtle.getItemCount(f) -- Gets current count of inventory slots 1 - 15
47-
  z = 1
47+
48-
  m = 0
48+
49-
  q = 0
49+
    print("Creating Dark Iron!")
50
    term.setCursorPos(1,1)
51
    if turtle.getItemCount(16)>0 and q>=897 then -- 896 = 14 stacks. If there's 897 items, we assume there's 14 stacks and 1 extra block. From there we just assume there's no more room in the invetory for extra items despite that there's really 63 spots. I don't care enough to change this.
52
      turtle.select(16)
53-
    if turtle.getItemCount(f)>0 or turtle.getItemCount(16)>0 then
53+
      turtle.drop()
54-
      term.setCursorPos(1,1)
54+
55-
      print("Creating Dark Iron!")
55+
    elseif turtle.getItemCount(16)>0 and q<897 then -- Now we can assume there's plenty of room for slot 16 to be left open and anything in slot 16 to be moved.
56-
      term.setCursorPos(1,1)
56+
      q = q + turtle.getItemCount(16) -- Seeing as we care about what's in slot 16 now, we have to add the count to "q."
57-
      q = q + turtle.getItemCount(f)
57+
      transfering()
58-
      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
58+
      turtle.select(1)
59-
        turtle.select(16)
59+
60-
        turtle.drop()
60+
    transfering() 
61-
        turtle.select(1) 
61+
    turtle.turnRight() -- Turns to face the flame.
62-
      elseif turtle.getItemCount(16)>0 and q<897 then
62+
    turtle.turnRight()
63-
        q = q + turtle.getItemCount(16)
63+
    turtle.select(1)
64-
        transfering()
64+
    while q>0 do
65-
        turtle.select(1)
65+
      turtle.place()
66-
      end 
66+
      sleep(3.3) -- Sleeps to make sure iron has converted.
67-
      turtle.turnRight()
67+
      turtle.dig()
68-
      turtle.turnRight()
68+
      wait() -- Checks to see if 10 blocks have been converted. Waits if so.
69-
      while q>0 do
69+
      transfering() -- Keeps slot 1 full.
70-
        checkInv()  
70+
      q = q - 1 -- One less block needs to be converted, so must take tahat into account.
71-
        turtle.place()
71+
72-
        sleep(3)
72+
    turtle.turnRight() -- Turns towards player.
73-
        turtle.dig()
73+
    turtle.turnRight()
74-
        wait(m)
74+
    for t = 1, 16 do  -- Gives items back.
75-
        q = q - 1 -- One less block of regular iron, so must take that into account
75+
      turtle.select(t)
76-
      end
76+
      turtle.drop()
77-
      turtle.turnRight()
77+
78-
      turtle.turnRight()
78+
    turtle.select(1)   
79-
      for t = 1, 16 do  
79+
  else -- If there are no items, it waits until it is given some.
80-
        turtle.select(t)
80+
81-
        turtle.drop()
81+
    sleep(1)      
82-
      end
82+
    print("Waiting!")
83
    sleep(1)
84-
    else
84+
85-
      b = 1
85+
86-
      z = 1
86+