Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor = peripheral.wrap("monitor_2")
- chest = peripheral.wrap("null_0")
- chestSize = chest.getSizeInventory() - 1
- startPosY = 3
- startPosX = 3
- buttonSizeX = 12
- buttonSizeY = 3
- buttonLabelMargin = 1
- buttonSizeLabel = buttonSizeX - (buttonLabelMargin * 2)
- idSafariNet = 12260
- itemTable = {}
- monitor.setBackgroundColor(colors.black)
- monitor.setTextScale(0.5)
- monitor.clear()
- function scanChest()
- for i = 0, chestSize do
- itemData = chest.getStackInSlot(i)
- if itemData == nil then
- itemTable[i] = nil
- else
- itemName = itemData["name"]
- itemID = itemData["id"]
- if itemID == idSafariNet then
- if string.len(itemName) > buttonSizeLabel then
- itemNameSize = buttonSizeLabel - 3
- itemNameLabel = string.sub(itemName, 1, itemNameSize).."..."
- else
- itemNameLabel = itemName
- end
- itemTable[i] = itemNameLabel
- end
- end
- end
- end
- function drawButtons()
- for doY = 1, 3 do
- curY = startPosY + (buttonSizeY * (doY - 1)) + (doY - 1)
- for doX = 1, 3 do
- curX = startPosX + (buttonSizeX * (doX - 1)) + (doX - 1)
- itemTablePos = ((3 * (doY - 1)) + doX) - 1
- monitor.setBackgroundColor(colors.blue)
- monitor.setCursorPos(curX, curY)
- monitor.write(string.rep(" ",buttonSizeX))
- monitor.setCursorPos(curX, curY + 1)
- monitor.write(string.rep(" ",buttonSizeX))
- if itemTablePos <= #itemTable then
- monitor.setCursorPos(curX + 1, curY + 1)
- monitor.write(itemTable[itemTablePos])
- end
- monitor.setCursorPos(curX, curY + 2)
- monitor.write(string.rep(" ",buttonSizeX))
- -- if doX < 3 then curX = curX + marginX
- -- end
- end
- end
- end
- scanChest()
- drawButtons()
- monitor.setBackgroundColor(colors.black)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement