Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- s.getAllStacks()[integer].all().display_name
- -- s.pushItem("south", slot, how many)
- -- Initalise
- rs.setOutput("top", false)
- drawers = peripheral.wrap("front")
- -- Make distal name:slot_ID table
- drawer_slots = {}
- for ID, slot in pairs(drawers.getAllStacks()) do
- drawer_slots[slot.all().id] = ID
- print(ID, " ", slot.all().id)
- end
- while true do
- local total = 0
- -- local inventory = {
- -- "minecraft:wheat" = 0,
- -- "minecraft:soul_sand" = 0,
- -- "minecraft:nether_star" = 0
- -- }
- -- Switch off redstone before counting
- rs.setOutput("top", false)
- -- Tabulate items in inventory
- for i = 1, 16 do
- item = turtle.getItemDetail(i)
- if item then
- -- inventory[item.name] += item.count
- total = total + item.count
- end
- end
- -- If inventory is empty, refill
- if total == 0 then
- local drawer_slot = 0
- -- One nether star
- drawer_slot = drawer_slots["minecraft:nether_star"]
- drawers.pushItem("south", drawer_slot, 1, 1)
- -- Forty wheat
- drawer_slot = drawer_slots["minecraft:wheat"]
- drawers.pushItem("south", drawer_slot, 40, 2)
- -- Four hundred soul sand
- drawer_slot = drawer_slots["minecraft:soul_sand"]
- for i = 3, 8 do
- drawers.pushItem("south", drawer_slot, 60, i)
- end
- -- And a partridge in a pear tree
- drawers.pushItem("south", drawer_slot, 40, 9)
- end
- -- Reenable redstone
- rs.setOutput("top", true)
- -- Yield
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment