Meteor Scripting Functions
Events
void onWorldStart()
Server only
Called after the map is loaded.
void onWorldStart()
{
print("onWorldStart: " + getWorldName());
}
void onPlayerSpawn(int playerID, bool respawn)
Server and clients
Called when any player spawns or respawns.
void onPlayerSpawn(int playerID, bool respawn)
{
if(playerID == getPlayer())
{
if(!respawn)
{
print("Welcome to " + getWorldName() + ", " + getUnitDisplayName(getPlayer()));
}
else
{
print("You respawned");
}
}
}
Use setSinglePlayerRespawnEnabled to enable single player respawn.
void onTriggerBoxEnter(int triggerBoxID, string triggerBoxTag, int objectID)
Server and clients (local only)
Called when any unit or player enters a trigger box.
void onTriggerBoxEnter(int triggerBoxID, string triggerBoxTag, int objectID)
{
print(getUnitDisplayName(objectID) + " entered trigger box " + triggerBoxID + " '" + triggerBoxTag + "'");
}
void onTriggerBoxExit(int triggerBoxID, string triggerBoxTag, int objectID)
Server and clients (local only)
Called when any unit or player exits a trigger box.
void onTriggerBoxExit(int triggerBoxID, string triggerBoxTag, int objectID)
{
print(getUnitDisplayName(objectID) + " left trigger box " + triggerBoxID + " '" + triggerBoxTag + "'");
}
void onTick(float tickDelta)
Server and clients (local only)
Called on each tick (normally 30 times per second).
void onTick(float tickDelta)
{
}
void onUpdate(float deltaTime)
Server and clients
Called rendered every frame.
void onUpdate(float tickDelta)
{
}
void onClientConnected(int playerId)
Server only
Called when a client connects.
void onClientConnected(int playerId)
{
print(getUnitDisplayName(playerId) + " just connected");
}
void onClientDisconnected(int playerId)
Server only
Called when a client connects.
void onClientDisconnected(int playerId)
{
print(getUnitDisplayName(playerId) + " has disconnected");
}
void onUnitSpawn(int objectId)
Server and clients
Called after a unit or player spawns.
void onUnitSpawn(int objectID)
{
print(getUnitDisplayName(objectId) + " spawned");
}
void onUnitTargetChanged(int objectId, int targetId)
Server only
Called when a unit's target has changed.
void onUnitTargetChanged(int objectId, int targetId)
{
if(targetId != -1)
print(getUnitDisplayName(objectId) + "(" + objectId + ")" + " target changed to " + getUnitDisplayName(targetId) + " (" + targetId + ")");
else
print(getUnitDisplayName(objectId) + "(" + objectId + ") target cancelled");
}
targetId -1 is no target.
void onUnitDamaged(int objectId, int ownerId, int oldHits, int newHits)
Server only
Called after a unit or player is damaged.
void onUnitDamaged(int objectId, int ownerId, int oldHits, int newHits)
{
print(getUnitDisplayName(objectID) + " was damaged by " + getUnitDisplayName(ownerId) + " and now has " + newHits + " health");
}
void onUnitKilled(int objectId, int killerId)
Server only
Called when a unit or player is killed.
void onUnitKilled(int objectId, int killerId)
{
print(getUnitDisplayName(objectId) + " was killed by " + getUnitDisplayName(killerId));
}
void onPickupItem(int playerID, string itemName, int itemAmount, string powerupName)
Server only
Called when any player picks up an item.
void onPickupItem(int playerID, string itemName, int itemAmount, string powerupName)
{
print(getUnitDisplayName(playerID) + " picked up " + itemAmount + "x " + itemName + " from the " + powerupName);
}
void onGameSave()
Single player only
Called while the game is being saved.
vector2 triggerPos = vector2(100, 100);
int someInt;
vector2 someVec1;
void onGameSave()
{
saveGameVar("someInt", someInt);
saveGameVar("someVec1", someVec1);
}
Use onGameSave to save global script variables.
void onGameLoad()
Single player only
Called while the game is being loaded.
vector2 triggerPos = vector2(100, 100);
int someInt;
vector2 someVec1;
void onGameLoad()
{
someInt = loadGameVar("someInt", 0);
someVec1 = loadGameVar("someVec1", vector2(0,0));
}
Index
Generated on the 15 May 2024 at 09:00:40 (UK Time)