Meteor 2 Scripting Functions
Spline
int createSplineNode(vector2 pos)
Create a spline node.

Example
// create node at player's position
int node = createSplineNode(getPos(PLAYER_OBJECT));

See also
deleteSplineNode

void deleteSplineNode(int nodeID)
Delete a spline node.

Example
// delete node ID 1
deleteSplineNode(1);

See also
createSplineNode

vector2 getSplineNodePos(int nodeID)
Get the position of a spline node.

Example
// output the position of spline node 1
print(getSplineNodePos(1));

See also
setSplineNodePos

void setSplineNodePos(int nodeID, vector2 pos)
set the position of a spline node.

Example
// move spline node 1 to the player's position
setSplineNodePos(1, getPos(PLAYER_OBJECT));

See also
getSplineNodePos

int createSplineSegment(string splineType, float minWidth, float maxWidth, float sideMinWidth, float sideMaxWidth, int startNodeID, int endNodeID, float tension=0)
Create a spline segment.

Example 1
// create randomly sized road segment between node 1 and 2
int segment = createSplineSegment("Road", -1, -1, -1, 1, 2, 0.5f);

Example 2
// create set size road segment between node 1 and 2
int segment = createSplineSegment("Road", 250, 250, 20, 1, 2, 0.8f);

Example 3
// create randomly sized railway segment between node 1 and 2
int segment = createSplineSegment("Railway (single)", -1, -1, -1, 1, 2, 0.5f);

Comments
If a width value is negative, the value will be set to the spline type default.
Tension is between -1 and 1 inclusive.

See also
deleteSplineSegment

void deleteSplineSegment(int segmentID)
Delete a spline segment.

Example
// delete segment ID 1
deleteSplineSegment(1);

See also
createSplineSegment

int getSplineSegmentStartNode(int segmentID)
Get the start node of a spline segment.

Example
// output the start node of spline segment 1
print(getSplineSegmentStartNode(1));

See also
getSplineSegmentEndNode

int getSplineSegmentEndNode(int segmentID)
Get the end node of a spline segment.

Example
// output the end node of spline segment 1
print(getSplineSegmentEndNode(1));

See also
getSplineSegmentStartNode

float getSplineSegmentMinWidth(int segmentID)
Get the minimum width of a spline segment.

Example
// output the minimum width of spline segment 1
print(getSplineSegmentMinWidth(1));

See also
setSplineSegmentMinWidth getSplineSegmentMaxWidth setSplineSegmentMaxWidth

void setSplineSegmentMinWidth(int segmentID, float minWidth)
Set the minimum width of a spline segment.

Example 1
// set the minimum width of spline segment 1
setSplineSegmentMinWidth(1, 100);

Example 2
// reset the minimum width of spline segment 1
setSplineSegmentMinWidth(1, -1);

Comments
If minWidth is negative, it will be set to the spline type default.

See also
getSplineSegmentMinWidth getSplineSegmentMaxWidth setSplineSegmentMaxWidth

float getSplineSegmentMaxWidth(int segmentID)
Get the maximum width of a spline segment.

Example
// output the maximum width of spline segment 1
print(getSplineSegmentMaxWidth(1));

See also
setSplineSegmentMaxWidth getSplineSegmentMinWidth setSplineSegmentMinWidth

void setSplineSegmentMaxWidth(int segmentID, float maxWidth)
Set the maximum width of a spline segment.

Example 1
// set the maximum width of spline segment 1
setSplineSegmentMaxWidth(1, 200);

Example 2
// reset the maximum width of spline segment 1
setSplineSegmentMaxWidth(1, -1);

Comments
If maxWidth is negative, it will be set to the spline type default.

See also
getSplineSegmentMaxWidth getSplineSegmentMinWidth setSplineSegmentMinWidth

float getSplineSegmentSideMinWidth(int segmentID)
Get the minimum side width of a spline segment.

Example
// output the minimum side width of spline segment 1
print(getSplineSegmentSideMinWidth(1));

See also
setSplineSegmentSideMinWidth getSplineSegmentSideMaxWidth setSplineSegmentSideMaxWidth

void setSplineSegmentSideMinWidth(int segmentID, float sideMinWidth)
Set the minimum side width of a spline segment.

Example 1
// set the minimum side width of spline segment 1
setSplineSegmentSideMinWidth(1, 10);

Example 2
// reset the minimum side width of spline segment 1
setSplineSegmentSideMinWidth(1, -1);

Comments
If sideMinWidth is negative, it will be set to the spline type default.

See also
getSplineSegmentSideMinWidth getSplineSegmentSideMaxWidth setSplineSegmentSideMaxWidth

float getSplineSegmentSideMaxWidth(int segmentID)
Get the maximum side width of a spline segment.

Example
// output the maximum side width of spline segment 1
print(getSplineSegmentSideMaxWidth(1));

See also
setSplineSegmentSideMaxWidth getSplineSegmentSideMinWidth setSplineSegmentSideMinWidth

void setSplineSegmentSideMaxWidth(int segmentID, float sideMaxWidth)
Set the maximum side width of a spline segment.

Example 1
// set the maximum side width of spline segment 1
setSplineSegmentSideMaxWidth(1, 20);

Example 2
// reset the maximum side width of spline segment 1
setSplineSegmentSideMaxWidth(1, -1);

Comments
If sideMaxWidth is negative, it will be set to the spline type default.

See also
getSplineSegmentSideMaxWidth getSplineSegmentSideMinWidth setSplineSegmentSideMinWidth

float getSplineSegmentTension(int segmentID)
Get the tension of a spline segment.

Example
// output the tension of spline segment 1
print(getSplineSegmentTension(1));

See also
setSplineSegmentTension

void setSplineSegmentTension(int segmentID, float tension)
Set the tension of a spline segment.

Example 1
// set the tension of spline segment 1
setSplineSegmentTension(1, 0.5);

Example 2
// reset the tension of spline segment 1
setSplineSegmentTension(1, 0);

Comments
Tension is limited to between -1 and 0.8 inclusive.

See also
getSplineSegmentTension

string getSplineSegmentSplineType(int segmentID)
Get the type of a spline segment.

Example
// output the type of spline segment 1
print(getSplineSegmentSplineType(1));

See also
setSplineSegmentSplineType

void setSplineSegmentSplineType(int segmentID, string splineType)
Set the type of a spline segment.

Example
// set the type of spline segment 1
setSplineSegmentSplineType(1, "River");

See also
getSplineSegmentSplineType

int getSplineSegmentTerrainType(int segmentID)
Get the terrain type of a spline segment.

Example
// output the terrain type of spline segment 1
print(getSplineSegmentTerrainType(1));

Comments
Valid terrain type values:
- TPT_LAND
- TPT_SOLID
- TPT_WATER
- TPT_OPEN
- TPT_CLOSED
- TPT_LOW_WALL

See also
setSplineSegmentTerrainType

void setSplineSegmentTerrainType(int segmentID, int terrainType)
Set the terrain type of a spline segment.

Example
// set the terrain type of spline segment 1
setSplineSegmentTerrainType(1, TPT_WATER);

Comments
Valid terrain type values:
- TPT_LAND
- TPT_SOLID
- TPT_WATER
- TPT_OPEN
- TPT_CLOSED
- TPT_LOW_WALL

See also
getSplineSegmentTerrainType

bool lockToSpline(int objectID, int nodeID, vector2 offset=vector2(0,0))
Lock the specified object to a spline (server only).

Example 1
// make object 1 follow spline node 2
lockToSpline(1, 2);

Example 2
// make object 1 follow spline node 2 offset to the left
lockToSpline(1, 2, vector2(50, 0));

Example 3
// make object 1 follow spline node 5 in reverse
lockToSpline(1, 5, vector2(0, 0), true);

Comments
The trailers of the specified object will also be locked.
The specified object will be teleported onto the spline.

See also
getLockedSplineNodeID

int getLockedSplineNodeID(int objectID)
Get the spline node ID the specified object is locked to (server only).

Example
// Get start node ID of spline object 1 is locked to
print(getLockedSplineNodeID(1));

Comments
Returns -1 if object is not locked to a spline.

See also
lockToSpline

float getLockedSplineLength(int objectID)
Get the length of the spline the specified object is locked to (server only).

Example
// Get total length of spline object 1 is locked to
print(getLockedSplineLength(1));

Comments
Returns 0 if object is not locked to a spline.

See also
lockToSpline

vector2 getLockedSplinePointFromDistance(int objectID, float distance)
Get the position of a point by total distance on the spline the specified object is locked to (server only).

Example
// Get point 100 pixels along spline object 1 is locked to
print(getLockedSplinePointFromDistance(1, 100));

Comments
Distance is in pixels.

See also
lockToSpline

vector2 getLockedSplinePointFromDistance(int objectID, float distance, float &out angle)
Get the position and angle of a point by total distance on the spline the specified object is locked to (server only).

Example
// Get point and angle 100 pixels along spline object 1 is locked to
float angle;
vector2 point = getLockedSplinePointFromDistance(1, 100, angle);
print("Spline point: " + point);
print("Spline angle at point is " + angle);

Comments
Distance is in pixels.

See also
lockToSpline

float getLockedSplineClosestDistanceTo(int objectID, vector2 pos)
Get the closest total distance to a position on the spline the specified object is locked to (server only).

Example
// Get total distance closest to (100, 100) on spline object 1 is locked to
print(getLockedSplinePointFromDistance(1, vector2(100, 100)));

Comments
Distance is in pixels.

See also
lockToSpline

vector2 getLockedSplineClosestPointTo(int objectID, vector2 pos)
Get the closest point to a position on the spline the specified object is locked to (server only).

Example
// Get point closest to (100, 100) on spline object 1 is locked to
print(getLockedSplineClosestPointTo(1, vector2(100, 100)));

See also
lockToSpline

vector2 getLockedSplineClosestPointTo(int objectID, vector2 pos, float &out angle)
Get the closest point and angle to a position on the spline the specified object is locked to (server only).

Example
// Get point and angle closest to (100, 100) on spline object 1 is locked to
float angle;
vector2 point = getLockedSplineClosestPointTo(1, vector2(100, 100), angle);
print("Closest point: " + point);
print("Spline angle at point is " + angle);

See also
lockToSpline


Index