Skip to content

External API

Christian Bronk edited this page Nov 7, 2018 · 7 revisions

The following calls are added to the API class, that will not change in the future:

the API is here: API.cs


public static string SpawnObject(string modelName)

Spawns a static object with the disiret model-name and starts the editor. The static is stored in the savegame. Returns the unique identifier of the static


public static void RemoveStatic(string uuid)

Destroys the static with the given uuid.


public static void HighLightStatic(string uuid, Color color)

Taints the static idientified by its uuid with a color. Use Color.clear to remove the taint.


public static string GetModelTitel(string uuid)

Returns the human readable model titel for a static. Usable for displaying a list of statics.


public static void SetEditorRange(float newRange)

Sets the maximum placement range of the reduced set statics editor, which is callable through the API (SpawnObject)


 public static GameObject GetGameObject(string uuid)  (>=v1.4.5.2)

Returns the GameObject of the static with the specified uuid


public static string PlaceStatic(string modelName, string bodyName,  double lat, double lng, float alt , float rotation , bool isScanable = false)

Places a static without openening the editor.


CallBack Functions

public static bool AddEnterTriggerCallback(string uuid, Action<Part> myFunction)
public static bool AddStayTriggerCallback(string uuid, Action<Part> myFunction)
public static bool AddExitTriggerCallback(string uuid, Action<Part> myFunction)

Theese three functions take a statics uuid and a function pointer of a function of the type void myfunc(Part shipPart) They register your function to a staics CallBack Module so your function gets called when a Ship-Part enters/stays/exits a trigger collider of a static object.

Example:

string tgtUUID = "c868c344-eb8b-4318-a3da-0462f49d6261";
public void MyEnterFunc (Part myPart)
{
    Debug.Log("The following vessel entered the Trigger Collider: " + myPart.vessel.name);
}
KerbalKonstructs.API.AddEnterTriggerCallback(tgtUUID, MyEnterFunc );