Advertisement
themadgod

forge

Oct 5th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. cGrind = peripheral.wrap("left")
  2. cSmelt = peripheral.wrap("chest_0")
  3. cOutput = peripheral.wrap("right")
  4.  
  5. blocks = {}
  6. size = cGrind.getInventorySize()
  7.  
  8. for i = 1, size, 1 do
  9. slot = cGrind.getStackInSlot(i)
  10. if slot then
  11. -- print(slot.display_name.." ..... " .. slot.qty)
  12. s = {name=slot.display_name, qty=slot.qty}
  13. table.insert(blocks, s)
  14. end
  15.  
  16. end
  17.  
  18. pos = 1
  19.  
  20. function handleKey(key)
  21. if key == keys.up and pos > 0 then
  22. pos = pos - 1
  23. elseif key == keys.down and pos < table.getn(blocks) then
  24. pos = pos + 1
  25. elseif key == keys.right then
  26. smelt()
  27. elseif key == keys.q then
  28. return nil
  29. end
  30. end
  31.  
  32. function draw(t, pos)
  33. term.clear()
  34. term.setCursorPos(4,4)
  35. for k,v in pairs(t) do
  36. term.write(v.name .. " ............. " ..v.qty)
  37. end
  38.  
  39. for i = 4, table.getn(t)+4, 1 do
  40. term.setCursorPos(2,i)
  41. if pos == i then
  42. term.write(">")
  43. end
  44. end
  45. end
  46.  
  47. while true do
  48.  
  49. draw(blocks, pos)
  50.  
  51. if pos == nil then break end
  52.  
  53. evt, key = os.pullEvent("key")
  54. pos = handleKey(key)
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement