Advertisement
jaklsfjlsak

自制语音激光制导

Mar 18th, 2025
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local ship = peripheral.find("warpdriveShipCore")
  2. local miningLaser = peripheral.find("warpdriveMiningLaser")
  3. local virtualAssistant = peripheral.find("warpdriveVirtualAssistant")
  4.  
  5.           ship_front, ship_right, ship_up = ship.dim_positive()
  6.           ship_back, ship_left, ship_down = ship.dim_negative()
  7.           ship_isInHyper = ship.isInHyperspace()
  8.           ship_movement = { ship.movement() }
  9.           ship_rotationSteps = ship.rotationSteps()
  10.  
  11. print("Post Way Point in Chat to Jump Ship and Aligning the Mining Laser")
  12.  
  13. while true do
  14.  
  15.     while true do
  16.     sleep(0.08)
  17.     local state = 0
  18.     local CMD = 0
  19.   state, CMD = virtualAssistant.pullLastCommand()
  20.     string = string.lower(CMD)
  21.  
  22.       -- Match and extract X and Z
  23.  local x_value, z_value = string:match("x:(%d+),%s*y:%d+,%s*z:(%d+)")
  24.     if state then
  25.         print("Jumpinig to X:" .. tonumber(x_value) .. ", Z:" .. tonumber(z_value))
  26.        
  27.         local rx, ry, rz = ship.getOrientation()
  28.         minForwardBack = math.abs(ship_front+ship_back+1)
  29.         minLeftRight = math.abs(ship_left+ship_right+1)
  30.         local mx, my, mz = miningLaser.getLocalPosition()
  31.             dx = x_value-mx
  32.             dz = z_value-mz
  33.        
  34.         forwardBackMov = 0
  35.         leftRightMov = 0
  36.  
  37.         if rx == 1 then
  38.             forwardBackMov = dx
  39.             leftRightMov = dz
  40.         elseif rx == -1 then
  41.             forwardBackMov = -dx
  42.             leftRightMov = -dz
  43.         elseif rz == 1 then
  44.             forwardBackMov = dz
  45.             leftRightMov = -dx
  46.         elseif rz == -1 then
  47.             forwardBackMov = -dz
  48.             leftRightMov = dx
  49.         end
  50.  
  51.         if math.abs(forwardBackMov) < minForwardBack and math.abs(leftRightMov) < minLeftRight then
  52.             print("The movement is too small!")
  53.         else
  54.    
  55.  
  56.         leftRightMov = leftRightMov*1
  57.             ship.movement(forwardBackMov, 0, leftRightMov)
  58.             ship.rotationSteps(0)
  59.             ship.command("MANUAL", true)
  60.  end
  61.         end
  62.     end
  63.  
  64.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement