Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script to control and eventually also monitor the xp bottler and xp collector from More Peripherals
- -- Script by craftersanonmoose
- -- Version history
- -- version 0.1 2/16/23
- -- adding controls
- -- version 0.1.1 2/16/23
- -- added button and display functionality
- -- version 0.1.2 2/16/23
- -- added error handling to allow script to run even if bottles run out in storage
- -- want to add in informational area for below the two buttons to show how much XP is in each colector
- ---------------------------
- os.loadAPI("button")
- mon = peripheral.find("monitor")
- mon.clear()
- -- change the name of peripheral if needed
- bottler = peripheral.wrap("xp_bottler_2")
- c0 = peripheral.wrap("xp_collector_8")
- c1 = peripheral.wrap("xp_collector_6")
- function fillTable()
- button.setTable("Collector1", bottle1, 4,14,3,5)
- button.setTable("Collector2", bottle2, 17,27,3,5)
- 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_6", "bettercrates:diamond_crate_6", "xp_collector_8")
- 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_6", "bettercrates:diamond_crate_6", "xp_collector_6")
- end)
- if not success then
- print("Error occured:", err)
- end
- end
- function showLevel()
- mon.setCursorPos(4,7)
- mon.write("XP Level")
- mon.setCursorPos(4,8)
- mon.clearLine()
- mon.write(c0.getCurrentXP())
- mon.setCursorPos(17,7)
- mon.write("XP Level")
- mon.setCursorPos(17,8)
- mon.write(c1.getCurrentXP())
- end
- fillTable()
- button.heading("XP Bottler")
- while true do
- showLevel()
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement