mawesome4ever

Ship Commands

Jun 21st, 2021
709
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local Hyper      = GetPartFromPort(1, "HyperDrive")
  2. local Rocket     = GetPartFromPort(2, "IonRocket")
  3. local LifeSensor = GetPartFromPort(4, "LifeSensor")
  4. local Butt       = GetPartFromPort(5, "Button")
  5. local Tele       = GetPartFromPort(6, "Telescope")
  6. local StarMap    = GetPartFromPort(7, "StarMap")
  7. local Gyro       = GetPartFromPort(10, "Gyro")
  8. local Instrument = GetPartFromPort(11, "Instrument")
  9.  
  10. local output    = GetPartFromPort(8, "Speaker")
  11. local input      = GetPartFromPort(9, "Microphone")
  12.  
  13. local owner      = "addictedroblox1414"
  14.  
  15. local Following  = false
  16. local AreTheyOn  = false
  17. local function ToggleThruster(Speed)
  18.     Rocket:Configure({Propulsion = Speed})
  19. end
  20.  
  21. local commands = {
  22.     come = function()
  23.         output:Chat("On my way!")
  24.     end;
  25.     follow = function()
  26.         output:Chat("Following master "..owner)
  27.         Following = true
  28.         while Following do
  29.             local Pos = LifeSensor:GetReading()[owner]
  30.             local CurrentPos = Instrument:GetReading(6)
  31.             if Pos then
  32.                 local TargetLoc  = Pos + Vector3.new(0, 15, 0)
  33.                 print("magn".. tostring((TargetLoc - CurrentPos).Magnitude))
  34.                 if (TargetLoc - CurrentPos).Magnitude <= 25 then
  35.                     ToggleThruster(0)
  36.                 else
  37.                     Gyro:PointAt(TargetLoc)
  38.                     ToggleThruster(math.floor((CurrentPos - TargetLoc).Magnitude))
  39.                 end
  40.             else print("player "..owner.."not found nearby"); Following = false; return end
  41.         end
  42.     end;
  43.     stop = function()
  44.         Following = false
  45.         ToggleThruster(0)
  46.         output:Chat("Stopped Following master "..owner)
  47.     end;
  48.     warp = function(FirstString, FullMessage)
  49.         local args = string.split(FullMessage, ",")
  50.         output:Chat("Warping to "..args[1]..","..args[2]..","..args[3]..","..args[4]..(args[5] and args[5] or ""))
  51.         Hyper:Configure({Coordinates = args[1]..", "..args[2]..", "..args[3]..", "..args[4]..(args[5] and ", "..args[5] or "")})
  52.         TriggerPort(Hyper)
  53.     end;
  54.     hover = function()
  55.         output:Chat("Hovering!")
  56.         ToggleThruster(0)
  57.     end;
  58.     door = function()
  59.         TriggerPort(Butt)
  60.         output:Chat("Toggling door!")
  61.     end;
  62.     shutoff = function()
  63.         output:Chat("Shutting down!")
  64.     end;
  65. }
  66.  
  67. local function Chatted(User, Message)
  68.     print("\""..User.."\"", "\""..Message.."\"")
  69.     if User ~= owner then return end
  70.     local args = string.split(Message, " ") or Message
  71.     print(args[1])
  72.     if #args > 0 and commands[args[1]] then
  73.         local command = args[1]
  74.         table.remove(args, 1)
  75.         commands[command](args, Message)
  76.     end
  77. end
  78. input:ConnectToEvent("Chatted", Chatted)
RAW Paste Data