Difference between revisions of "Oolite JavaScript OM Specification"
From Elite Wiki
(Changed properties/instance variables to be consistently lowercase.) |
(Removed already-implemented classes Vector and Quaternion, changed categories, expanded note.) |
||
| Line 1: | Line 1: | ||
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. |
||
| − | '''Note:''' this is a work in progress. It should not be taken as a final specification. |
+ | '''Note:''' this is a work in progress. It should not be taken as a final specification. Much of the functionality has been redesigned already. See [[:Category:Oolite scripting]] for current documentation and [[:Category:Oolite scripting drafts]] for in-progress documentation. |
| − | <pre> |
||
| + | class Commodity |
||
| − | class Vector3 |
||
| + | { |
||
| − | { |
||
| + | readonly string name; |
||
| − | float x, z, y; |
||
| + | 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 <del>Vessel</del><ins>Ship</ins> |
||
| + | { |
||
| + | 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); |
||
| + | } |
||
| − | class Quaternion |
||
| + | [[Category:Oolite scripting drafts]] |
||
| − | { |
||
| − | 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 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); |
||
| − | } |
||
| − | </pre> |
||
| − | |||
| − | [[Category:Oolite Development]] |
||
Revision as of 15:42, 3 August 2007
Use this page to define the object model exposed by Oolite to the JavaScript interpreter.
Note: this is a work in progress. It should not be taken as a final specification. Much of the functionality has been redesigned already. See Category:Oolite scripting for current documentation and Category:Oolite scripting drafts for in-progress documentation.
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);
}