Meteor 2 Scripting Functions
Spline
int createSplineNode(vector2 pos)
Create a spline node.
int node = createSplineNode(getPos(PLAYER_OBJECT));
void deleteSplineNode(int nodeID)
Delete a spline node.
deleteSplineNode(1);
vector2 getSplineNodePos(int nodeID)
Get the position of a spline node.
print(getSplineNodePos(1));
void setSplineNodePos(int nodeID, vector2 pos)
set the position of a spline node.
setSplineNodePos(1, getPos(PLAYER_OBJECT));
int createSplineSegment(string splineType, float minWidth, float maxWidth, float sideMinWidth, float sideMaxWidth, int startNodeID, int endNodeID, float tension=0)
Create a spline segment.
int segment = createSplineSegment("Road", -1, -1, -1, 1, 2, 0.5f);
int segment = createSplineSegment("Road", 250, 250, 20, 1, 2, 0.8f);
int segment = createSplineSegment("Railway (single)", -1, -1, -1, 1, 2, 0.5f);
If a width value is negative, the value will be set to the spline type default.
Tension is between -1 and 1 inclusive.
void deleteSplineSegment(int segmentID)
Delete a spline segment.
deleteSplineSegment(1);
int getSplineSegmentStartNode(int segmentID)
Get the start node of a spline segment.
print(getSplineSegmentStartNode(1));
int getSplineSegmentEndNode(int segmentID)
Get the end node of a spline segment.
print(getSplineSegmentEndNode(1));
float getSplineSegmentMinWidth(int segmentID)
Get the minimum width of a spline segment.
print(getSplineSegmentMinWidth(1));
void setSplineSegmentMinWidth(int segmentID, float minWidth)
Set the minimum width of a spline segment.
setSplineSegmentMinWidth(1, 100);
setSplineSegmentMinWidth(1, -1);
If minWidth is negative, it will be set to the spline type default.
float getSplineSegmentMaxWidth(int segmentID)
Get the maximum width of a spline segment.
print(getSplineSegmentMaxWidth(1));
void setSplineSegmentMaxWidth(int segmentID, float maxWidth)
Set the maximum width of a spline segment.
setSplineSegmentMaxWidth(1, 200);
setSplineSegmentMaxWidth(1, -1);
If maxWidth is negative, it will be set to the spline type default.
float getSplineSegmentSideMinWidth(int segmentID)
Get the minimum side width of a spline segment.
print(getSplineSegmentSideMinWidth(1));
void setSplineSegmentSideMinWidth(int segmentID, float sideMinWidth)
Set the minimum side width of a spline segment.
setSplineSegmentSideMinWidth(1, 10);
setSplineSegmentSideMinWidth(1, -1);
If sideMinWidth is negative, it will be set to the spline type default.
float getSplineSegmentSideMaxWidth(int segmentID)
Get the maximum side width of a spline segment.
print(getSplineSegmentSideMaxWidth(1));
void setSplineSegmentSideMaxWidth(int segmentID, float sideMaxWidth)
Set the maximum side width of a spline segment.
setSplineSegmentSideMaxWidth(1, 20);
setSplineSegmentSideMaxWidth(1, -1);
If sideMaxWidth is negative, it will be set to the spline type default.
float getSplineSegmentTension(int segmentID)
Get the tension of a spline segment.
print(getSplineSegmentTension(1));
void setSplineSegmentTension(int segmentID, float tension)
Set the tension of a spline segment.
setSplineSegmentTension(1, 0.5);
setSplineSegmentTension(1, 0);
Tension is limited to between -1 and 0.8 inclusive.
string getSplineSegmentSplineType(int segmentID)
Get the type of a spline segment.
print(getSplineSegmentSplineType(1));
void setSplineSegmentSplineType(int segmentID, string splineType)
Set the type of a spline segment.
setSplineSegmentSplineType(1, "River");
int getSplineSegmentTerrainType(int segmentID)
Get the terrain type of a spline segment.
print(getSplineSegmentTerrainType(1));
Valid terrain type values:
- TPT_LAND
- TPT_SOLID
- TPT_WATER
- TPT_OPEN
- TPT_CLOSED
- TPT_LOW_WALL
void setSplineSegmentTerrainType(int segmentID, int terrainType)
Set the terrain type of a spline segment.
setSplineSegmentTerrainType(1, TPT_WATER);
Valid terrain type values:
- TPT_LAND
- TPT_SOLID
- TPT_WATER
- TPT_OPEN
- TPT_CLOSED
- TPT_LOW_WALL
bool lockToSpline(int objectID, int nodeID, vector2 offset=vector2(0,0))
Lock the specified object to a spline (server only).
lockToSpline(1, 2);
lockToSpline(1, 2, vector2(50, 0));
lockToSpline(1, 5, vector2(0, 0), true);
The trailers of the specified object will also be locked.
The specified object will be teleported onto the spline.
int getLockedSplineNodeID(int objectID)
Get the spline node ID the specified object is locked to (server only).
print(getLockedSplineNodeID(1));
Returns -1 if object is not locked to a spline.
float getLockedSplineLength(int objectID)
Get the length of the spline the specified object is locked to (server only).
print(getLockedSplineLength(1));
Returns 0 if object is not locked to a spline.
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).
print(getLockedSplinePointFromDistance(1, 100));
Distance is in pixels.
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).
float angle;
vector2 point = getLockedSplinePointFromDistance(1, 100, angle);
print("Spline point: " + point);
print("Spline angle at point is " + angle);
Distance is in pixels.
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).
print(getLockedSplinePointFromDistance(1, vector2(100, 100)));
Distance is in pixels.
vector2 getLockedSplineClosestPointTo(int objectID, vector2 pos)
Get the closest point to a position on the spline the specified object is locked to (server only).
print(getLockedSplineClosestPointTo(1, vector2(100, 100)));
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).
float angle;
vector2 point = getLockedSplineClosestPointTo(1, vector2(100, 100), angle);
print("Closest point: " + point);
print("Spline angle at point is " + angle);
Index