Advertisement
ccraftersanonmoose

test xp collector script

Feb 16th, 2023 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | Gaming | 0 0
  1. -- Test script to add buttons to the xp controller script for More Peripherals
  2. -- made by craftersanonmoose
  3. -- version 0.1 2/16/23
  4. -- adding buttons to original script
  5. -- detecting monitor, currently set to wrap left but will change for final implementation to detect with find
  6. -- modifying for blaze xp farm with 4 collectors numbered 2 - 5
  7.  
  8. ----------------------------------
  9. os.loadAPI("button")
  10. mon = peripheral.find("monitor")
  11. mon.clear()
  12.  
  13. -- change the name of peripheral if needed
  14. bottler = peripheral.wrap("xp_bottler_1")
  15. c2 = peripheral.wrap("xp_collector_2")
  16. c3 = peripheral.wrap("xp_collector_3")
  17. c4 = peripheral.wrap("xp_collector_4")
  18. c5 = peripheral.wrap("xp_collector_5")
  19.  
  20.  
  21.  
  22. function fillTable()
  23. button.setTable("Collector1", bottle1, 4,14,3,5)
  24. button.setTable("Collector2", bottle2, 17,27,3,5)
  25. button.setTable("Collector3", bottle3, 4,14,7,9)
  26. button.setTable("Collector4", bottle4, 17,27,7,9)
  27. button.screen()
  28. end
  29.  
  30. function getClick()
  31. event,side,x,y = os.pullEvent("monitor_touch")
  32. button.checkxy(x,y)
  33. end
  34.  
  35.  
  36. -- I used a diamond crate for this, change the name based on your storgae method
  37. function bottle1()
  38. button.flash("Collector1")
  39. local success, err = pcall(function()
  40. bottler.bottleXP("bettercrates:diamond_crate_7", "bettercrates:diamond_crate_7", "xp_collector_2")
  41. end)
  42. if not success then
  43. print("Error occured:", err)
  44. end
  45. end
  46.  
  47. function bottle2()
  48. button.flash("Collector2")
  49. local success, err = pcall(function()
  50. bottler.bottleXP("bettercrates:diamond_crate_7", "bettercrates:diamond_crate_7", "xp_collector_3")
  51. end)
  52. if not success then
  53. print("Error occured:", err)
  54. end
  55. end
  56.  
  57. function bottle3()
  58. button.flash("Collector3")
  59. local success, err = pcall(function()
  60. bottler.bottleXP("bettercrates:diamond_crate_7", "bettercrates:diamond_crate_7", "xp_collector_4")
  61. end)
  62. if not success then
  63. print("Error occured:", err)
  64. end
  65. end
  66.  
  67. function bottle4()
  68. button.flash("Collector4")
  69. local success, err = pcall(function()
  70. bottler.bottleXP("bettercrates:diamond_crate_7", "bettercrates:diamond_crate_7", "xp_collector_5")
  71. end)
  72. if not success then
  73. print("Error occured:", err)
  74. end
  75. end
  76.  
  77. function showLevel()
  78. mon.setCursorPos(1,10)
  79. mon.write("XP:")
  80. mon.setCursorPos(4,10)
  81. mon.write("1:")
  82. mon.setCursorPos(6,10)
  83. mon.write(c2.getCurrentXP())
  84. mon.setCursorPos(4,11)
  85. mon.write("2:")
  86. mon.setCursorPos(6,11)
  87. mon.write(c3.getCurrentXP())
  88. mon.setCursorPos(17,10)
  89. mon.write("3:")
  90. mon.setCursorPos(19,10)
  91. mon.write(c4.getCurrentXP())
  92. mon.setCursorPos(17,11)
  93. mon.write("4:")
  94. mon.setCursorPos(19,11)
  95. mon.write(c5.getCurrentXP())
  96. end
  97.  
  98.  
  99. fillTable()
  100. button.heading("XP Bottler")
  101.  
  102. while true do
  103. showLevel()
  104. getClick()
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement