Skip to content

Instantly share code, notes, and snippets.

@johnbartholomew
Created May 14, 2013 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbartholomew/5576299 to your computer and use it in GitHub Desktop.
Save johnbartholomew/5576299 to your computer and use it in GitHub Desktop.
Pioneer autopilot test script
RepeatJourney = true
local journeys = {}
Event.Register('onGameStart', function ()
journeys = {}
end)
Event.Register('onShipDocked', function (ship, station)
local journey = journeys[ship]
if journey then
print(ship.label .. ' docked with ' .. station.label .. '; destroying it')
ship:Explode()
journeys[ship] = nil
if RepeatJourney then
TestJourney(journey.from, journey.to)
end
end
end)
Event.Register('onShipUndocked', function (ship, station)
local journey = journeys[ship]
if journey then
print(ship.label .. ' undocked from ' .. station.label .. '; sending it to ' .. journey.to.label)
ship:AIDockWith(journey.to)
end
end)
Event.Register('onShipDestroyed', function (ship)
journeys[ship] = nil
end)
-- Los Angeles is index 9
-- Gates Spaceport is index 10
-- Poseidon Station is index 46
-- Clarke's Station is index 25
function TestJourney(from_station, to_station)
from_station = from_station or Space.GetBody(9) -- Los Angeles
to_station = to_station or Space.GetBody(10) -- Gates Spaceport
test_ship = Space.SpawnShipDocked('wave', from_station)
test_ship:SetLabel('Test')
test_ship:AddEquip('AUTOPILOT', 1)
test_ship:AddEquip('ATMOSPHERIC_SHIELDING', 1)
journeys[test_ship] = { from = from_station, to = to_station }
test_ship:Undock()
return test_ship
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment