Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require "component"
- local transposer = component.transposer
- local sides = require "sides"
- local redstone = component.redstone
- local inputChest = sides.up--Chest that has the input items
- local craftingChest = sides.north--Chest that has crafting items and ready to be extracted
- local terrasteel = {"Manasteel Ingot", "Mana Pearl", "Mana Diamond"}
- function getAmount(container, checkAmountOf)--container: side of the container ; item: label of the item
- inventory = transposer.getAllStacks(container)
- tmp = 0
- for i = 1, inventory.count() do
- if inventory[i].label == checkAmountOf then
- tmp = tmp + 1
- end
- end
- return tmp
- end
- function amountIsValid(container, amount, item)--container: side of the inventory that we are checking the amount of ; item: label of the item
- return amount < getAmount(container, item)
- end
- function moveItem(source, destination, amount, item)
- sourceSlots = transposer.getAllStacks(source)
- if amountIsValid(source, amount, item) then
- return true, -1
- else
- missing = amount - getAmount(source, item)
- return false, missing
- end
- end
- function startCrafting()
- input = transposer.getAllStacks(inputChest)
- for i=1, 3 do
- if getAmount(input, terrasteel[i]) < 0 then
- _, missing = moveItem(inputChest, craftingChest, 1, terrasteel[i])
- print(missing .. "many "..terrasteel[i].." is missing")
- return nil
- end
- end
- redstone.setOutput(sides.north, 15)
- os.sleep(2)
- redstone.setOutput(sides.up, 15)
- print("The item is crafting...")
- end
- startCrafting()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement