Advertisement
ccraftersanonmoose

Enchanting Interface Button

Feb 22nd, 2023 (edited)
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.32 KB | Gaming | 0 0
  1. -- Script to allow enchanting via button
  2. -- Written by craftersanonmoose
  3. -- version history
  4. -- version 0.1
  5. -- button to click on attached monitor
  6. -- version 0.2
  7. -- adding in ability to view xp levels in collectors
  8. -- this is system is also connected to the blaze and spider xp collectors
  9. -- wanting to add ability to bittle xp from this system as well
  10. ----------------------------
  11.  
  12. os.loadAPI("button")
  13. mon = peripheral.find("monitor")
  14. mon.clear()
  15.  
  16. -- change the name of peripheral if needed
  17. enchanter = peripheral.wrap("enchanting_interface_0")
  18. bottler0 = peripheral.wrap("xp_bottler_2")
  19. bottler1 = peripheral.wrap("xp_bottler_1")
  20. c0 = peripheral.wrap("xp_collector_8")
  21. c1 = peripheral.wrap("xp_collector_9")
  22. c2 = peripheral.wrap("xp_collector_2")
  23. c3 = peripheral.wrap("xp_collector_3")
  24. c4 = peripheral.wrap("xp_collector_4")
  25. c5 = peripheral.wrap("xp_collector_5")
  26.  
  27.  
  28.  
  29. function fillTable()
  30.     button.setTable("Collector1", bottle1, 4,14,3,5)
  31.     button.setTable("Collector2", bottle2, 17,27,3,5)
  32.     button.setTable("Collector3", bottle3, 4,14,7,9)
  33.     button.setTable("Collector4", bottle4, 17,27,7,9)
  34.     button.setTable("Collector5", bottle5, 4,14,11,13)
  35.     button.setTable("Collector6", bottle6, 17,27,11,13)
  36.     button.setTable("Enchant", enchant, 10,20,15,15)
  37.     button.screen()
  38. end
  39.  
  40. function getClick()
  41.     event,side,x,y = os.pullEvent("monitor_touch")
  42.     button.checkxy(x,y)
  43. end
  44.  
  45.  
  46. -- Vanilla storage is needed for this interface, change the name based on your storgae method
  47. function enchant()
  48.     button.flash("Enchant")
  49.     local success, err = pcall(function()
  50.        enchanter.enchant("minecraft:chest_1", 1, "minecraft:chest_1")
  51.     end)
  52.     if not success then
  53.         print("Error occured:", err)
  54.     end
  55. end
  56.  
  57. -- I used a diamond crate for this, change the name based on your storgae method
  58. function bottle1()
  59.     button.flash("Collector1")
  60.     local success, err = pcall(function()
  61.        bottler0.bottleXP("minecraft:chest_1", "minecraft:chest_1", "xp_collector_8")
  62.     end)
  63.     if not success then
  64.         print("Error occured:", err)
  65.     end
  66. end
  67.  
  68. function bottle2()
  69.     button.flash("Collector2")
  70.     local success, err = pcall(function()
  71.        bottler0.bottleXP("minecraft:chest_1", "minecraft:chest_1", "xp_collector_9")
  72.     end)
  73.     if not success then
  74.         print("Error occured:", err)
  75.     end
  76. end
  77.  
  78. function bottle3()
  79.     button.flash("Collector3")
  80.     local success, err = pcall(function()
  81.        bottler1.bottleXP("minecraft:chest_1", "minecraft:chest_1", "xp_collector_2")
  82.     end)
  83.     if not success then
  84.         print("Error occured:", err)
  85.     end
  86. end
  87.  
  88. function bottle4()
  89.     button.flash("Collector4")
  90.     local success, err = pcall(function()
  91.        bottler1.bottleXP("minecraft:chest_1", "minecraft:chest_1", "xp_collector_3")
  92.     end)
  93.     if not success then
  94.         print("Error occured:", err)
  95.     end
  96. end
  97.  
  98. function bottle5()
  99.     button.flash("Collector5")
  100.     local success, err = pcall(function()
  101.        bottler1.bottleXP("minecraft:chest_1", "minecraft:chest_1", "xp_collector_4")
  102.     end)
  103.     if not success then
  104.         print("Error occured:", err)
  105.     end
  106. end
  107.  
  108. function bottle6()
  109.     button.flash("Collector6")
  110.     local success, err = pcall(function()
  111.        bottler1.bottleXP("minecraft:chest_1", "minecraft:chest_1", "xp_collector_5")
  112.     end)
  113.     if not success then
  114.         print("Error occured:", err)
  115.     end
  116. end
  117.  
  118.  
  119. function showLevel()
  120.     mon.setCursorPos(1,17)
  121.     mon.clearLine()
  122.     mon.write("Levels")
  123.     mon.setCursorPos(7,17)
  124.     mon.write("1:")
  125.     mon.setCursorPos(9,17)
  126.     mon.write(c0.getCurrentXP())
  127.     mon.setCursorPos(17,17)
  128.     mon.write("2:")
  129.     mon.setCursorPos(19,17)
  130.     mon.write(c1.getCurrentXP())
  131.     mon.setCursorPos(7,18)
  132.     mon.clearLine()
  133.     mon.write("3:")
  134.     mon.setCursorPos(9,18)
  135.     mon.write(c2.getCurrentXP())
  136.     mon.setCursorPos(7,19)
  137.     mon.clearLine()
  138.     mon.write("4:")
  139.     mon.setCursorPos(9,19)
  140.     mon.write(c3.getCurrentXP())
  141.     mon.setCursorPos(17,18)
  142.     mon.write("5:")
  143.     mon.setCursorPos(19,18)
  144.     mon.write(c4.getCurrentXP())
  145.     mon.setCursorPos(17,19)
  146.     mon.write("6:")
  147.     mon.setCursorPos(19,19)
  148.     mon.write(c5.getCurrentXP())
  149. end
  150.  
  151.  
  152. fillTable()
  153. button.heading("Bottle Filler & Enchanter")
  154.  
  155. while true do
  156.     showLevel()
  157.     getClick()
  158. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement