Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cGrind = peripheral.wrap("left")
- cSmelt = peripheral.wrap("chest_0")
- cOutput = peripheral.wrap("right")
- blocks = {}
- size = cGrind.getInventorySize()
- for i = 1, size, 1 do
- slot = cGrind.getStackInSlot(i)
- if slot then
- -- print(slot.display_name.." ..... " .. slot.qty)
- s = {name=slot.display_name, qty=slot.qty}
- table.insert(blocks, s)
- end
- end
- pos = 1
- function handleKey(key)
- if key == keys.up and pos > 0 then
- pos = pos - 1
- elseif key == keys.down and pos < table.getn(blocks) then
- pos = pos + 1
- elseif key == keys.right then
- smelt()
- elseif key == keys.q then
- return nil
- end
- end
- function draw(t, pos)
- term.clear()
- term.setCursorPos(4,4)
- for k,v in pairs(t) do
- term.write(v.name .. " ............. " ..v.qty)
- end
- for i = 4, table.getn(t)+4, 1 do
- term.setCursorPos(2,i)
- if pos == i then
- term.write(">")
- end
- end
- end
- while true do
- draw(blocks, pos)
- if pos == nil then break end
- evt, key = os.pullEvent("key")
- pos = handleKey(key)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement