Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ores = {"iron_", "tin_", "copper_", "lead_", "silver_", "gold_", "platinum_", "nickel_", "aluminum_"}
- currentOre = 1
- function nextOre()
- name = string.lower(ores[currentOre])
- if currentOre == #ores then
- currentOre = 1
- else
- currentOre = currentOre +1
- end
- return name
- end
- function nextOreSlots()
- local ore = nextOre()
- local oreSlots = {}
- print("Looking for "..ore)
- for tSlot=1,16 do
- -- turtle.select(tSlot)
- local details = turtle.getItemDetail(tSlot)
- if details ~= nil then
- name = string.lower(details.name)
- print("--"..name.."--")
- if string.match(name, ore) ~= nil then
- --turtle slot contains active ore
- oreSlots[#oreSlots+1] = tSlot
- end
- end
- end
- return oreSlots
- end
- function dropSlots(oreSlots)
- for i=1,#oreSlots do
- local tSlot = oreSlots[i]
- print("Dropping slot "..tSlot.." in smeltery")
- turtle.select(tSlot)
- turtle.dropUp()
- end
- end
- function hasLiquid(smelter)
- local content = smelter.getInfo().contents
- if not content then
- return false
- else
- local name = content.rawName
- local amount = content.amount
- --print("--found "..name.."("..amount.." mB)")
- return true
- end
- end
- function hasSolid(smelter)
- local size = smelter.getInventorySize()
- for slot=1,size do
- local s = smelter.getStackInSlot(slot)
- if s ~= nil then
- local name = s.name
- --print("--found "..name.." in slot "..slot)
- return true
- end
- end
- return false
- end
- function isSmelterBusy(side)
- local smelter = peripheral.wrap(side)
- local s = hasSolid(smelter)
- local l = hasLiquid(smelter)
- return s or l
- end
- while true do
- while isSmelterBusy("top") do
- sleep(1)
- end
- dropSlots(nextOreSlots())
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement