Advertisement
giwdul

backpack minecraft

Jun 10th, 2025 (edited)
761
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. -- Version simple pour afficher une fois sur le monitor
  2.  
  3. local backpack = peripheral.wrap("right")  -- Changez la direction
  4. local monitor = peripheral.wrap("top")     -- Changez la direction
  5.  
  6. if not backpack or not monitor then
  7.     print("Vérifiez les connexions du sac et du monitor")
  8.     return
  9. end
  10.  
  11. -- Rediriger vers le monitor
  12. term.redirect(monitor)
  13. monitor.setTextScale(0.5)
  14.  
  15. -- Effacer l'écran
  16. term.clear()
  17. term.setCursorPos(1, 1)
  18.  
  19. -- Affichage
  20. print("=== CONTENU DU SAC ===")
  21. print()
  22.  
  23. local items = {}
  24. for slot = 1, backpack.size() do
  25.     local item = backpack.getItemDetail(slot)
  26.     if item then
  27.         local name = item.displayName or item.name
  28.         items[name] = (items[name] or 0) + item.count
  29.     end
  30. end
  31.  
  32. if next(items) == nil then
  33.     print("Sac vide")
  34. else
  35.     for name, count in pairs(items) do
  36.         print(count .. "x " .. name)
  37.     end
  38. end
  39.  
  40. print()
  41. print("MAJ: " .. textutils.formatTime(os.time(), false))
  42.  
  43. -- Revenir au terminal principal
  44. term.redirect(term.native())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement