Advertisement
nayoshi12

Untitled

Jun 13th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. os.loadAPI("touchpoint")
  2. local chest = peripheral.wrap("back")
  3. local t = touchpoint.new("left")
  4. local mon = peripheral.wrap("left")
  5.  
  6. local contents = chest.getAllStacks(false)
  7.  
  8. local x,y = mon.getSize()
  9. local left_margin1 = 2;
  10. local left_margin2 = math.floor(x/2-1);
  11. local right_margin1 =math.floor(x/2+1);
  12. local right_margin2 = x-1;
  13. local rows = (y-2)/2
  14. local books = {}
  15.  
  16.  
  17. function newBook(name,slot)
  18. local object = {}
  19. object.name = name
  20. if slot < 1 then
  21. object.slot = 0
  22. else
  23. object.slot = slot
  24. end
  25.  
  26. if slot<=rows then
  27. index = slot-1;
  28. t:add(name,nil,left_margin1,2+((2*index)+1),left_margin2,2+((2*index)+1),colors.red,colors.lime)
  29. elseif slot<=(rows*2) then
  30. index = (slot-7)-1;
  31. t:add(name,nil,right_margin1,2+((2*index)+1),right_margin2,2+((2*index)+1),colors.red,colors.lime)
  32. end
  33. return object
  34. end
  35.  
  36. function setTitle(str)
  37. x,y = mon.getSize()
  38. mon.clear()
  39. startPt = (x-#str)/2
  40. mon.setCursorPos(x-startPt,1)
  41. mon.setTextScale(1)
  42. mon.write(str)
  43. end
  44. print(rows)
  45. for i=1,#contents do
  46. local name = contents[i].myst_book.destination
  47. local slot = i
  48. print(name .. " " .. slot)
  49. books[i] = newBook(name,slot)
  50. end
  51. t:draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement