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