Advertisement
abobich

main.lua

Apr 16th, 2024 (edited)
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | Gaming | 0 0
  1. require 'calculate_angles'
  2. require 'get_angles'
  3.  
  4. local args = {...}
  5. local scanner = peripheral.wrap('playerDetector_0')
  6. local monitor = peripheral.wrap('monitor_0')
  7. local player_name = args[1]
  8. local x, y, z = args[2], args[3], args[4]
  9. local clutch_hor = peripheral.wrap('redstoneIntegrator_4')
  10. local clutch_vert = peripheral.wrap('redstoneIntegrator_5')
  11. local reverse_hor = peripheral.wrap('redstoneIntegrator_6')
  12. local reverse_vert = peripheral.wrap('redstoneIntegrator_7')
  13.  
  14. while true do
  15.     local target_pos = scanner.getPlayerPos(player_name)
  16.     local target_angles = calculate_angles(x, y, z, target_pos['x'], target_pos['y'], target_pos['z'])
  17.     local cannon_angles = get_angles()
  18.     print("Target:", target_angles['horizontal'], target_angles['vertical'])
  19.     print("Cannon:", cannon_angles['horizontal'], cannon_angles['vertical'])
  20.     clutch_hor.setOutput('top', math.abs(target_angles['horizontal']-cannon_angles['horizontal']) < 3)
  21.     clutch_vert.setOutput('top', math.abs(target_angles['vertical']-cannon_angles['vertical']) < 3)
  22.     reverse_hor.setOutput('top', target_angles['horizontal'] > cannon_angles['horizontal'])
  23.     reverse_vert.setOutput('top', target_angles['vertical'] > cannon_angles['vertical'])
  24. end
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement