Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script to allow anvil use via buttons
- -- written by craftersanonmoose
- -- would like to be able to capture user input for renaming
- ----------------------------------------
- os.loadAPI("button")
- mon = peripheral.find("monitor")
- mon.clear()
- -- change the name of peripheral if needed
- anvil = peripheral.wrap("anvil_interface_0")
- function fillTable()
- button.setTable("Rename", rename, 4,14,3,5)
- button.setTable("Combine", combine, 17,27,3,5)
- button.screen()
- end
- function getClick()
- event,side,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- -- Vanilla storage is needed for this interface, change the name based on your storgae method
- function rename()
- button.flash("Rename")
- local success, err = pcall(function()
- newName = read()
- anvil.rename("minecraft:chest_2", 1, newName)
- end)
- if not success then
- print("Error occured:", err)
- end
- end
- function combine()
- button.flash("Combine")
- local success, err = pcall(function()
- anvil.combine("minecraft:chest_2", 1, "minecraft:chest_2", 2, "minecraft:chest_2")
- end)
- if not success then
- print("Error occured:", err)
- end
- end
- fillTable()
- button.heading("Anvil")
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement