Advertisement
ccraftersanonmoose

grinder interface

Feb 24th, 2023 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | Gaming | 0 0
  1. -- Script to work with grinder interface and xp collector
  2. -- written by craftersanonmoose
  3. -- version history
  4. -- version 0.1
  5. -- should display amount of xp in collector as well as turn on the grinder
  6. -- may add in bottling ability later
  7. -- version 0.2
  8. -- added in button to turn on a wall lamp connected to a redstone integrator
  9. --------------------------------------------------
  10.  
  11. os.loadAPI("button")
  12. mon = peripheral.wrap("right")
  13. mon.clear()
  14.  
  15. -- change name of these as needed
  16. c9 = peripheral.wrap("xp_collector_9")
  17. grinder = peripheral.wrap("grinder_0")
  18. ri = peripheral.wrap("redstoneIntegrator_1")
  19.  
  20.  
  21. function fillTable()
  22.     -- Reactor Section
  23.     button.setTable("Light On", lightOn, 2,8,7,9)
  24.     button.setTable("Light Off", lightOff, 10,16,7,9)
  25.     button.screen()
  26. end
  27.  
  28. function getClick()
  29.     event,side,x,y = os.pullEvent("monitor_touch")
  30.     button.checkxy(x,y)
  31. end
  32.  
  33. function showLevel()
  34.     mon.setCursorPos(1,3)
  35.     mon.write("Collector:")
  36.     mon.setCursorPos(11,3)
  37.     mon.write(c9.getCurrentXP())
  38. end
  39.  
  40. function murder()
  41.     local success, err = pcall(function()
  42.        grinder.attack()
  43.        sleep(3)
  44.     end)
  45.     if not success then
  46.         print("Error occured:", err)
  47.     end
  48. end
  49.  
  50. function lightOn()
  51.     ri.setAnalogOutput("front", 15)
  52.     button.flash("Light")
  53. end
  54.  
  55. function lightOff()
  56.     ri.setAnalogOutput("front", 0)
  57.     button.flash("Light")
  58.  
  59. fillTable()
  60. button.heading("Mob Grinder")
  61.  
  62. while true do
  63.     showLevel()
  64.     murder()
  65.     getClick()
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement