Meteor 2 Scripting Functions
Audio
void playSound(string soundName)
Play a sound locally without spatialisation.
playSound("world\\battle");
void playSoundNumber(string soundName, instanceID soundName)
Play a sound by number (faster) locally without spatialisation and support instanceID (looping).
int rainSoundNumber = -1;
void storeSoundNumbers()
{
rainSoundNumber = getSoundNumber("ambience\\Rain_A");
}
void onWorldsStart()
{
storeSoundNumbers();
}
void onGameLoad()
{
storeSoundNumbers();
}
void onUpdate(float deltaTime)
{
playSoundNumber(rainSoundNumber, "AMB_RAIN_SOUND");
}
Pass instanceID as "" to play a one shot sound.
Pass instanceID as a unique string and call playSoundNumber every frame to play a loop (stop calling to stop the sound).
void playSoundDelayed(string soundName, float delayInSeconds)
Play a sound locally without spatialisation after a specified delay in seconds.
playSoundDelayed("world\\battle", 2);
void playSound2D(vector2 pos, string soundName)
Play a one shot sound from a 2D position.
playSound2D(getPos(PLAYER_OBJECT), "world\\battle");
If run from the server the sound is also played on all clients.
If run from a client the sound is local only.
void playSoundNumber2D(vector2 pos, int soundNumber, string instanceID)
Play a sound by number (faster) from a 2D position and support instanceID (looping).
int soundNumber = getSoundNumber("world\\battle");
if(soundNumber != -1)
playSoundNumber2D(getPos(PLAYER_OBJECT), soundNumber, "");
If run from the server the sound is also played on all clients.
If run from a client the sound is local only.
Pass instanceID as "" to play a one shot sound.
Pass instanceID as a unique string and call playSoundNumber2D every frame to play a loop (stop calling to stop the sound).
void getSoundNumber(string effectName)
Get a sound number from a sound effect name.
int soundNumber = getSoundNumber("world\\battle");
print(soundNumber);
Returns -1 if the sound effect does not exist.
void playMusic(string musicFileName)
Play music from file.
playMusic("1996.mod");
Pass a filename only to search in base\music.
Pass an absolute path to play from another location.
Supported formats include Ogg Vorbis, MOD, S3M, XM.
float getMusicPos()
Get the currently playing music position in seconds.
print(getMusicPos())
void setMusicPos(float seconds)
Seek the currently playing music to the current position in seconds.
setMusicPos(30);
string getMusicFilename()
Get the currently playing music filename.
print(getMusicFilename())
void stopMusic()
Stop music playing.
stopMusic();
Music is stopped and cannot be resumed (use playMusic to play more music).
Music will not resume until a new level is started.
void restartMusic()
Rewind currently playing music to the start.
restartMusic();
void pauseMusic()
Pause currently playing music.
pauseMusic();
void resumeMusic()
Resume current music.
resumeMusic();
void isMusicPaused()
Is music paused?
if(isMusicPaused())
{
print("Music is paused");
}
else
{
print("Music is not paused");
}
Index
Generated on the 23 November 2024 at 08:20:40 (UK Time)