Advertisement
TheDieselPunk

Attac

May 9th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. --- pastebin get 4XF7EwMD attac
  2. --- This script fires a laser in the direction the player is looking when they sneak.
  3.  
  4. --- Firstly we want to ensure that we have a neural interface and wrap it.
  5. local modules = peripheral.find("neuralInterface")
  6. local kinetic = peripheral.wrap(--[[ whatever ]])
  7. if not modules then
  8.     error("Must have a neural interface", 0)
  9. end
  10.  
  11. --- We require an introspection module and entity sensor to get the direction the player is facing in. Obviously a laser
  12. --- is required too.
  13. if not modules.hasModule("plethora:sensor") then
  14.     error("Must have an entity sensor", 0)
  15. end
  16. if not modules.hasModule("plethora:introspection") then
  17.     error("Must have an introspection module", 0)
  18. end
  19.  
  20.  
  21. --- Now that we're all set up, we loop forever. First we get the player's metadata and check they're sneaking. If so we
  22. --- fire a laser and sleep to allow the energy buffer to refil. Otherwise we sleep for a short period of time before
  23. --- checking again.
  24. while true do
  25.     local meta = modules.getMetaOwner()
  26.     if meta.isSneaking then
  27.         kinetic.swing()
  28.         sleep(0.2)
  29.     else
  30.         sleep(0.1)
  31.     end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement