Advertisement
Guest User

test

a guest
Oct 20th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1. monitor = peripheral.wrap("monitor_2")
  2. chest = peripheral.wrap("null_0")
  3. chestSize = chest.getSizeInventory() - 1
  4.  
  5. startPosY = 3
  6. startPosX = 3
  7. buttonSizeX = 12
  8. buttonSizeY = 3
  9. buttonLabelMargin = 1
  10. buttonSizeLabel = buttonSizeX - (buttonLabelMargin * 2)
  11. idSafariNet = 12260
  12. itemTable = {}
  13.  
  14. monitor.setBackgroundColor(colors.black)
  15. monitor.setTextScale(0.5)
  16. monitor.clear()
  17.  
  18. function scanChest()
  19.   for i = 0, chestSize do  
  20.     itemData = chest.getStackInSlot(i)
  21.     if itemData == nil then
  22.       itemTable[i] = nil
  23.     else
  24.       itemName = itemData["name"]
  25.       itemID = itemData["id"]
  26.       if itemID == idSafariNet then
  27.         if string.len(itemName) > buttonSizeLabel then
  28.           itemNameSize = buttonSizeLabel - 3
  29.           itemNameLabel = string.sub(itemName, 1, itemNameSize).."..."
  30.         else
  31.           itemNameLabel = itemName
  32.         end
  33.         itemTable[i] = itemNameLabel
  34.       end
  35.     end
  36.   end
  37. end
  38.  
  39. function drawButtons()
  40.   for doY = 1, 3 do
  41.     curY = startPosY + (buttonSizeY * (doY - 1)) + (doY - 1)
  42.     for doX = 1, 3 do
  43.       curX = startPosX + (buttonSizeX * (doX - 1)) + (doX - 1)
  44.       itemTablePos = ((3 * (doY - 1)) + doX) - 1
  45.       monitor.setBackgroundColor(colors.blue)
  46.       monitor.setCursorPos(curX, curY)
  47.       monitor.write(string.rep(" ",buttonSizeX))
  48.       monitor.setCursorPos(curX, curY + 1)
  49.       monitor.write(string.rep(" ",buttonSizeX))
  50.       if itemTablePos <= #itemTable then
  51.         monitor.setCursorPos(curX + 1, curY + 1)
  52.         monitor.write(itemTable[itemTablePos])
  53.       end
  54.       monitor.setCursorPos(curX, curY + 2)
  55.       monitor.write(string.rep(" ",buttonSizeX))
  56. --      if doX < 3 then curX = curX + marginX
  57. --      end
  58.     end
  59.   end
  60. end
  61.  
  62. scanChest()
  63. drawButtons()
  64. monitor.setBackgroundColor(colors.black)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement