-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathironcycler.lua
More file actions
58 lines (49 loc) · 1.16 KB
/
ironcycler.lua
File metadata and controls
58 lines (49 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
local settings = {
drainSide = "top",
signalSide = "front",
extractColor = colors.red,
insertColor = colors.green,
interval = 60
}
function mainLoop()
print("IronCycler started.")
init()
redstone.setBundledOutput(settings.signalSide, settings.insertColor)
while true do
if isBottomLiquidIron() then
print("Bottom liquid is iron, cycling...")
cycle()
end
wait(settings.interval)
end
end
function init()
redstone.setOutput(settings.signalSide, false)
redstone.setBundledOutput(settings.signalSide, 0)
end
function wait(secs)
print("Waiting " .. secs .. " seconds.")
os.sleep(secs)
end
function isBottomLiquidIron()
local p = peripheral.wrap(settings.drainSide)
local t = p.getTankInfo()
if t == nil or t[1] == nil or t[1].contents == nil then
return false
end
if t[1].contents.name == "iron.molten" then
return true
else
return false
end
end
function cycle()
print("Extracting molten iron...")
redstone.setBundledOutput(settings.signalSide, settings.extractColor)
while isBottomLiquidIron() do
os.sleep(1)
end
print("Re-inserting molten iron...")
redstone.setBundledOutput(settings.signalSide, settings.insertColor)
end
mainLoop()