Advertisement
Vodka51200

monitorscancoffre

Jun 20th, 2017 (edited)
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. while true do
  2. --term.clear()
  3. local items = {}
  4. local max = 27
  5. local colors2 = {
  6.   ["Block of Diamond"] = colors.blue,
  7.   ["Iron Ingot"] = colors.gray,
  8.   ["Gold Ore"] = colors.yellow,
  9.   ["Gold Ingot"] = colors.yellow,
  10.   ["Block of Gold"] = colors.yellow,
  11.   -- Ajouter autant de blocs que vous le souhaitez avec leur couleur correspondante
  12. }
  13. local p = peripheral.wrap("left")
  14.  
  15. local function getItems(items, max)
  16.   for slot = 1, max do
  17.     --if p.getStackInSlot(slot) ~= nil then
  18.       --if p.getItemMeta(slot) ~= nil then
  19.       --local scan = p.getStackInSlot(slot)
  20.       local scan = p.getItemMeta(slot)
  21.       if scan then
  22.         items[scan.displayName] = (items[scan.displayName] or 0) + (scan.count or 0) -- display_name qty
  23.       end
  24.     --end
  25.   end
  26. end
  27.  
  28. local function displayItems(items, side)
  29.   local monitor = peripheral.wrap(side)
  30.   term.setBackgroundColor(colors.cyan)
  31.   --monitor.setTextScale(0.5)
  32.   --term.setCursorPos(1,1)
  33.   term.clear()
  34.   local y = 1
  35.   for k,v in pairs(items) do
  36.     term.setTextColor(colors2[k] or colors.white) -- Utiliser la couleur de la table ou la couleur blanche par défaut
  37.     term.setCursorPos(1, y)
  38.     print(y.. " " ..k.." x"..v)
  39.     y = y + 1
  40.   end
  41. end
  42.  
  43.  
  44.   getItems(items, max)
  45.   displayItems(items, "right")
  46.   sleep(0.5)
  47. end
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement