Advertisement
UpZone

CC - Inventory

Jun 29th, 2016
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---------------
  2. -- BY UPZONE --
  3. ---------------
  4.  
  5. os.loadAPI("builder\\apis\\Colors")
  6.  
  7. function getItemCount(slots)
  8.     count = 0
  9.     for i, v in pairs(slots) do
  10.         count = count + turtle.getItemCount(v)
  11.     end
  12.     return count
  13. end
  14.  
  15. function itemCountStatus(count, slots)
  16.     currentCount = getItemCount(slots)
  17.     if currentCount > count then
  18.         currentCount = count
  19.     end
  20.     countStringLength = string.len(tostring(count))
  21.     text = string.format("[%0" .. countStringLength.. "d/" .. count .. "]", currentCount)
  22.  
  23.     if currentCount >= count then
  24.         -- enough items
  25.         term.blit(text, string.rep(Colors.lime, string.len(text)), string.rep(Colors.black, string.len(text)))
  26.         return true
  27.     else
  28.         -- not enough
  29.         term.blit(text, string.rep(Colors.red, string.len(text)), string.rep(Colors.black, string.len(text)))
  30.         return false
  31.     end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement