Oolite JavaScript OM Specification

From Elite Wiki
Revision as of 04:27, 25 March 2007 by Dajt (talk | contribs) (New page: Use this page to define the object model exposed by Oolite to the JavaScript interpreter. The syntax used should be obvious to anyone with some OO programming experience. <tt><pre> class...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Use this page to define the object model exposed by Oolite to the JavaScript interpreter.

The syntax used should be obvious to anyone with some OO programming experience.

class Vector3
{
	float x, z, y;
}

class Quaternion
{
	float x, y, z, w;
}

class Commodity
{
	readonly string Name;
	readonly integer unitofMass; // grams, kgs, tons
}

class Consignment
{
	Commodity commodity;
	float quantity;
}

class Entity
{
	readonly integer ID;
	readonly Entity[] subentities;
	Vector3 position;
	Vector3 velocity;
	Quaternion rotation;
	// some property to set change in rotation per second?

	static Entity getEntityWithID(integer ID);
	
	void setAI(string AIName);
	void pushAI(string AIName);
	void popAI();
}

// Note all methods which take an Entity as an argument can also accept an entity ID instead.
class Vessel
{
	float foreShieldStrength;
	float aftShieldStrength;
	float energy;

	float foreShieldMaxStrength;
	float aftShieldMaxStrength;
	float maxEnergy;

	// something measure of max and current hull integrity?

	// need to represent docking ports somehow

	float cabinTemperature;
	integer maxCargoCapacity;
	integer freeCargoCapacity;

	Consignment[] cargo;

	Entity currentTarget;
	Entity[] escorts;

	string roleName;
	string commanderName;
	
	// short form of getScanClassRelativeTo(0) - ie the player
	integer getScanClass();
	integer getScanClassRelativeTo(Entity other);

	float getDistanceFrom(Entity other);
	void Goto(Vector3 destination);
	void GotoEntity(Entity other, integer minimumDistance);

	// These methods return the ID of the launched entity, or -1 on error or if the target vessel cannot
	// launch other vessels.
	integer launchVesselWithRole(string role);
	integer launchVesselWithName(string name);
}