Advertisement
jaklsfjlsak

Dirk 自动驾驶

Mar 24th, 2025 (edited)
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. ```lua
  2. local core = peripheral.find("warpdriveShipCore")
  3. core.enable(true)
  4. core.command("IDLE", false)
  5.    
  6. -- Make sure the temp file exists --
  7. if fs.exists("temp") then
  8. else
  9.     fs.open("temp", "w")
  10.     local h = fs.open("temp", "w")
  11.     h.close()
  12. end
  13. ------------------------------------
  14.  
  15.     local h = fs.open("temp", "r")
  16.     if h.readAll() == "t" then
  17.         h.close()
  18.         print("Continually jumping...")
  19.         --local core = peripheral.find("warpdriveShipCore")
  20.        
  21.         --local h = fs.open("temp", "r")
  22.         --if h.readAll() == "t" then
  23.             --h.close()
  24.             core.enable(true)
  25.             core.command("IDLE", false)
  26.             sleep(1)
  27.             core.command("MANUAL", true)
  28.         --end
  29.        
  30.         print("Press `space` to stop jumping")
  31.        
  32.         local event, key = os.pullEvent("key")
  33.         if key == keys.space then
  34.             local h = fs.open("temp", "w")
  35.             h.writeLine("f")
  36.             h.close()
  37.             print("Movement stopped for next jump")
  38.         end
  39.  
  40.     else
  41.    
  42.     h.close()    
  43.  
  44.     print("Please input forward movement: ")
  45.     ForMove = tonumber(read())
  46.     print("Please input lateral movement: ")
  47.     LatMove = tonumber(read())
  48.     print("Please input vertical movement: ")
  49.     VerMove = tonumber(read())
  50.  
  51.     core.movement(ForMove, VerMove, LatMove)
  52.  
  53.     print("Starting continual jumping")
  54.     print("Press `Space` after a jump to stop jumping")
  55.  
  56.     core.command("MANUAL", true)
  57.     print("Starting Auto-pilot")
  58.  
  59.     local h = fs.open("temp", "w")
  60.     h.write("t")
  61.     h.close()
  62.  
  63. end
  64. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement