Difference between revisions of "Oolite JavaScript OM Specification"

From Elite Wiki
(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...)
 
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
'''This document is entirely outdated and kept only for historical purposes. For actual Oolite JavaScript interfaces, see [[:Category:Oolite JavaScript Reference|Oolite JavaScript Reference]].
 +
 
Use this page to define the object model exposed by Oolite to the JavaScript interpreter.
 
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 Commodity
 
+
{
<tt><pre>
+
readonly string name;
class Vector3
+
readonly integer unitofMass; // grams, kgs, tons
{
+
}
float x, z, y;
+
}
+
class Consignment
 
+
{
class Quaternion
+
Commodity commodity;
{
+
float quantity;
float x, y, z, w;
+
}
}
+
 
+
class Entity
class Commodity
+
{
{
+
readonly integer ID;
readonly string Name;
+
readonly Entity[] subentities;
readonly integer unitofMass; // grams, kgs, tons
+
Vector3 position;
}
+
Vector3 velocity;
 
+
Quaternion rotation;
class Consignment
+
// some property to set change in rotation per second?
{
+
Commodity commodity;
+
static Entity getEntityWithID(integer ID);
float quantity;
+
}
+
void setAI(string AIName);
 
+
void pushAI(string AIName);
class Entity
+
void popAI();
{
+
}
readonly integer ID;
+
readonly Entity[] subentities;
+
// Note all methods which take an Entity as an argument can also accept an entity ID instead.
Vector3 position;
+
class <del>Vessel</del><ins>Ship</ins>
Vector3 velocity;
+
{
Quaternion rotation;
+
float foreShieldStrength;
// some property to set change in rotation per second?
+
float aftShieldStrength;
 
+
float energy;
static Entity getEntityWithID(integer ID);
+
+
float foreShieldMaxStrength;
void setAI(string AIName);
+
float aftShieldMaxStrength;
void pushAI(string AIName);
+
float maxEnergy;
void popAI();
+
}
+
// something measure of max and current hull integrity?
 
+
// Note all methods which take an Entity as an argument can also accept an entity ID instead.
+
// need to represent docking ports somehow
class Vessel
+
{
+
float cabinTemperature;
float foreShieldStrength;
+
integer maxCargoCapacity;
float aftShieldStrength;
+
integer freeCargoCapacity;
float energy;
+
 
+
Consignment[] cargo;
float foreShieldMaxStrength;
+
float aftShieldMaxStrength;
+
Entity currentTarget;
float maxEnergy;
+
Entity[] escorts;
 
+
// something measure of max and current hull integrity?
+
string roleName;
 
+
string commanderName;
// need to represent docking ports somehow
+
 
+
// short form of getScanClassRelativeTo(0) - ie the player
float cabinTemperature;
+
integer getScanClass();
integer maxCargoCapacity;
+
integer getScanClassRelativeTo(Entity other);
integer freeCargoCapacity;
+
 
+
float getDistanceFrom(Entity other);
Consignment[] cargo;
+
void noto(Vector3 destination);
 
+
void notoEntity(Entity other, integer minimumDistance);
Entity currentTarget;
+
Entity[] escorts;
+
// These methods return the ID of the launched entity, or -1 on error or if the target vessel cannot
 
+
// launch other vessels.
string roleName;
+
integer launchVesselWithRole(string role);
string commanderName;
+
integer launchVesselWithName(string name);
+
}
// 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
+
[[Category:Oolite scripting]]
// launch other vessels.
 
integer launchVesselWithRole(string role);
 
integer launchVesselWithName(string name);
 
}
 
</pre></tt>
 

Latest revision as of 02:19, 22 January 2016

This document is entirely outdated and kept only for historical purposes. For actual Oolite JavaScript interfaces, see Oolite JavaScript Reference.

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

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 VesselShip
{
	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 noto(Vector3 destination);
	void notoEntity(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);
}