Advertisement
ccraftersanonmoose

Anvil interface buttons

Feb 24th, 2023
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | Gaming | 0 0
  1. -- Script to allow anvil use via buttons
  2. -- written by craftersanonmoose
  3. -- would like to be able to capture user input for renaming
  4. ----------------------------------------
  5.  
  6.  
  7. os.loadAPI("button")
  8. mon = peripheral.find("monitor")
  9. mon.clear()
  10.  
  11. -- change the name of peripheral if needed
  12. anvil = peripheral.wrap("anvil_interface_0")
  13.  
  14. function fillTable()
  15.     button.setTable("Rename", rename, 4,14,3,5)
  16.     button.setTable("Combine", combine, 17,27,3,5)
  17.     button.screen()
  18. end
  19.  
  20. function getClick()
  21.     event,side,x,y = os.pullEvent("monitor_touch")
  22.     button.checkxy(x,y)
  23. end
  24.  
  25.  
  26. -- Vanilla storage is needed for this interface, change the name based on your storgae method
  27. function rename()
  28.     button.flash("Rename")
  29.     local success, err = pcall(function()
  30.        newName = read()
  31.        anvil.rename("minecraft:chest_2", 1, newName)
  32.     end)
  33.     if not success then
  34.         print("Error occured:", err)
  35.     end
  36. end
  37.  
  38. function combine()
  39.     button.flash("Combine")
  40.     local success, err = pcall(function()
  41.        anvil.combine("minecraft:chest_2", 1, "minecraft:chest_2", 2, "minecraft:chest_2")
  42.     end)
  43.     if not success then
  44.         print("Error occured:", err)
  45.     end
  46. end
  47.  
  48. fillTable()
  49. button.heading("Anvil")
  50.  
  51. while true do
  52.     getClick()
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement