Meteor 2 Scripting Functions
Prefab
bool loadPrefab(string filename, vector2 pos, float angle, bool broadcast=true)
Additive load a map into the current map.

Example
loadPrefab("prefabs\\Sample_OneRoom.map", getPos(PLAYER_OBJECT), 0);
updateSectors();

Comments
Filename is relative to base\maps (or modfolder\maps).
The prefab map's settings and base sector are ignored.
The prefab map's start points and message triggers are ignored.
The prefab map will be positioned with the centre of it's geometry at the specified pos.
Matching IDs (e.g. sector IDs) are not guaranteed in multiplayer.
Call updateSectors() after loading prefabs to apply changes. If loading multiple prefabs call updateSectors() once after loading.

See also
updateSectors

int getPrefabTypesCount()
Get the number of available prefab types (maps marked as "Prefab").

Example
print(getPrefabTypesCount());

Comments
Returns the number of map files in the base\maps folder (inlcuding sub-folders) that have Is Prefab set to true in the Map Properties.

See also
getPrefabTypeFilename getPrefabTypeDescription getPrefabTypeSize

string getPrefabTypeFilename(int prefabTypeIndex)
Get a prefab type filename by index.

Example
// show first prefab type map filename
print(getPrefabTypeFilename(1));

Comments
All prefab maps are indexed when the game data is loaded and stored in the list of prefab types.
Prefab type 0 is always empty (default prefab).

See also
getPrefabTypeDescription getPrefabTypeSize getPrefabTypesCount

string getPrefabTypeDescription(int prefabTypeIndex)
Get a prefab type description by index.

Example
// show first prefab type description (map title)
print(getPrefabTypeDescription(1));

Comments
All prefab maps are indexed when the game data is loaded and stored in the list of prefab types.
Prefab type 0 is always empty (default prefab).

See also
getPrefabTypeFilename getPrefabTypeSize getPrefabTypesCount

vector2 getPrefabTypeSize(int prefabTypeIndex)
Get a the dimension in pixels of a prefab type by index.

Example
// show first prefab type size in pixels
print(getPrefabTypeSize(1));

Comments
All prefab maps are indexed when the game data is loaded and stored in the list of prefab types.
Prefab type 0 is always empty (default prefab).
Size is in pixels (not metres) and does not include the base sector or placed objects.

See also
getPrefabTypeFilename getPrefabTypeDescription getPrefabTypesCount


Index