VTOL VR API

The mod loader comes with an API which mod creators can use to help them do basic tasks, this API is currently very simple but later on with more discoveries and the development of the mod loader its self, this API should hopefully expand with more functionality.

Contents

Setup

To find the API all you need to do is get the instance variable from the static class then store that in a variable. Later on, all you have to call is "api" if you want to use a function from the API.

private VTOLAPI api;
private void Start()
{
    api = VTOLAPI.instance;
}

GetSteamID

GetSteamID returns the users steam id which can be used to identify the user's steam profile. This function uses Steamworks and returns as a ulong.

Debug.Log("This is the users SteamID: " + VTOLAPI.instance.GetSteamID())

GetSteamName

GetSteamName returns the users current steam name which is on their steam profile, please remember though this name can be changed by the player at any time. This function uses Steamworks and returns as a string.

Debug.Log("This is the users Steam Name: " + VTOLAPI.instance.GetSteamName())

GetPlayersVehicleGameObject

This returns the game object of the vehicle which the player is flying if the vehicle was not found, it will just return null so make sure to have a null check!

GameObject currentVehicle = VTOLAPI.GetPlayersVehicleGameObject();

GetPlayersVehicleEnum

This returns an enum to help identify which vehicle the player is currently using. This can be used if you have specific code to run depending on what vehicle is being used.

VTOLVehicles currentVehicle = VTOLAPI.GetPlayersVehicleEnum(); 
//Possible Returns: None, AV42C, FA26B, F45A

Waiting for scenario to finish loading

Run code when the scene has finished loading.

public override void ModLoaded()
{
    VTOLAPI.SceneLoaded += SceneLoaded;
    base.ModLoaded();
}

private void SceneLoaded(VTOLScenes scene)
{
    switch (scene)
    {
        case VTOLScenes.ReadyRoom:
            break;
        case VTOLScenes.Akutan:
        case VTOLScenes.CustomMapBase:
            Log("Map Loaded");
            break;
        case VTOLScenes.LoadingScene:
            break;
    }
}

Waiting for mission to be reloaded

MissionReloaded gets invoked whenever the user is in a mission and reloads it from a quicksave or restarts it from death.

public override void ModLoaded()
{
    VTOLAPI.MissionReloaded += MissionReloaded;
    base.ModLoaded();
}

private void MissionReloaded()
{
    //My Amazing Code to run when the user reloads the mission
}

GetUsersMods

If you need to check what mods the user has loaded, you can call GetUsersMods() to get a list of the type Mod which has the basic information about that mod (and some other stuff the mod loader uses) It also displays them in order which they were loaded.

public override void Start()
{
    List<Mod> mods = VTOLAPI.GetUsersMods();
    for (int i = 0; i < mods.Count; i++)
    {
        Log($"{mods[i].name} dll is located at {mods[i].dllPath}");
    }
}