Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local input = peripheral.wrap("front")
- or error("Unable to wrap input chest!",0)
- local output = peripheral.wrap("bottom")
- or error("Unable to wrap output chest!",0)
- local signal = "back"
- -- side of the redstone torch
- local inputslot = 1
- local fuelslot = 2
- local outputslot = 3
- -- slots inside furnace inv
- local fuel = {
- -- {id=number,dmg=number,burn=number}
- -- burn = burntime, how many items
- -- the fuel can burn.
- -- ex: coal/charcoal burns 8
- -- and wood burns 1.5
- {id=263,dmg=0,burn=8},--coal
- {id=263,dmg=1,burn=8},--charcoal
- --{id=5,dmg=-1,burn=1.5},--planks
- --{id=17,dmg=-1,burn=1.5},--wood
- --{id=6,dmg=-1,burn=.5},--sapling
- --{id=280,dmg=0,burn=.5},--stick
- }
- local furnaceToOutput = "west"
- local inputToFurnace = "down"
- local inputSlot = 1
- local outputSlot = 3
- -- returns statement,fuel
- -- statement = boolean
- -- fuel = table
- local function isFuel(item)
- for _,fuel in pairs(fuel) do
- if item.id == fuel.id
- and (item.dmg == fuel.dmg
- or fuel.dmg == -1) then
- return true,fuel
- end
- end
- return false
- end
- -- returns slot,fuel,item
- local function findFuel()
- local items = input.getAllStacks()
- for slot,item in pairs(items) do
- local state,fuel = isFuel(item)
- if state then
- return slot,fuel
- end
- end
- end
- -- returns slot,item
- local function findItem()
- local slot,fuel = findFuel()
- if slot and fuel then
- local items = input.getAllStacks()
- for slot,item in pairs(items) do
- local state = isFuel(item)
- if not state then
- if item.qty >= fuel.burn then
- return slot,item
- end
- end
- end
- end
- end
- local function emptyFurnace()
- output.pullItem("east",outputslot,64)
- end
- local function cook()
- -- if furnace is empty
- if rs.getInput(signal) == false then
- -- get fuel and item
- local fuelslot,fuel,fueli = findFuel()
- local itemslot,item = findItem()
- -- no fuel/item found: cancel out
- if not fuel then return end
- if not item then return end
- -- # items to move
- local fuelmove = math.floor(item.qty/fuel.burn)
- local itemmove = item.qty-(item.qty%fuel.burn)
- -- move items
- input.pushItemIntoSlot("down",fuelslot,fuelmove,fuelslot)
- input.pushItemIntoSlot("down",itemslot,itemmove,inputslot)
- end
- end
- cook()
Advertisement
Add Comment
Please, Sign In to add comment