Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Test script to add buttons to the xp controller script for More Peripherals
- -- made by craftersanonmoose
- -- version 0.1 2/16/23
- -- adding buttons to original script
- -- detecting monitor, currently set to wrap left but will change for final implementation to detect with find
- -- modifying for blaze xp farm with 4 collectors numbered 2 - 5
- ----------------------------------
- os.loadAPI("button")
- mon = peripheral.find("monitor")
- mon.clear()
- -- change the name of peripheral if needed
- bottler = peripheral.wrap("xp_bottler_1")
- c2 = peripheral.wrap("xp_collector_2")
- c3 = peripheral.wrap("xp_collector_3")
- c4 = peripheral.wrap("xp_collector_4")
- c5 = peripheral.wrap("xp_collector_5")
- function fillTable()
- button.setTable("Collector1", bottle1, 4,14,3,5)
- button.setTable("Collector2", bottle2, 17,27,3,5)
- button.setTable("Collector3", bottle3, 4,14,7,9)
- button.setTable("Collector4", bottle4, 17,27,7,9)
- button.screen()
- end
- function getClick()
- event,side,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- -- I used a diamond crate for this, change the name based on your storgae method
- function bottle1()
- button.flash("Collector1")
- local success, err = pcall(function()
- bottler.bottleXP("bettercrates:diamond_crate_7", "bettercrates:diamond_crate_7", "xp_collector_2")
- end)
- if not success then
- print("Error occured:", err)
- end
- end
- function bottle2()
- button.flash("Collector2")
- local success, err = pcall(function()
- bottler.bottleXP("bettercrates:diamond_crate_7", "bettercrates:diamond_crate_7", "xp_collector_3")
- end)
- if not success then
- print("Error occured:", err)
- end
- end
- function bottle3()
- button.flash("Collector3")
- local success, err = pcall(function()
- bottler.bottleXP("bettercrates:diamond_crate_7", "bettercrates:diamond_crate_7", "xp_collector_4")
- end)
- if not success then
- print("Error occured:", err)
- end
- end
- function bottle4()
- button.flash("Collector4")
- local success, err = pcall(function()
- bottler.bottleXP("bettercrates:diamond_crate_7", "bettercrates:diamond_crate_7", "xp_collector_5")
- end)
- if not success then
- print("Error occured:", err)
- end
- end
- function showLevel()
- mon.setCursorPos(1,10)
- mon.write("XP:")
- mon.setCursorPos(4,10)
- mon.write("1:")
- mon.setCursorPos(6,10)
- mon.write(c2.getCurrentXP())
- mon.setCursorPos(4,11)
- mon.write("2:")
- mon.setCursorPos(6,11)
- mon.write(c3.getCurrentXP())
- mon.setCursorPos(17,10)
- mon.write("3:")
- mon.setCursorPos(19,10)
- mon.write(c4.getCurrentXP())
- mon.setCursorPos(17,11)
- mon.write("4:")
- mon.setCursorPos(19,11)
- mon.write(c5.getCurrentXP())
- end
- fillTable()
- button.heading("XP Bottler")
- while true do
- showLevel()
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement