Smart Kitty
Well-known member
Hi everyone. A quick question, is there a way to change the music level with scripts?
spawn Boss1
@script
void main()
{
void self = getlocalvar("self");
int Check = getglobalvar("Boss1");
if(Check==6){
killentity(self);
} else {
playmusic("data/music/boss.bor",1);
}
}
@end_script
coords 550 460 1
at 0
I never used it before but it seems to be in same section as playsample so i suppose that it can be used like playsampleplaymusic(name, loop, offset)
- Pauses the music abruptly. technically, it toggles the variable ‘sound_pause_music’, commonly used for the pause menu to stop the music while the pause menu is present.
- name: pathname
- loop: toggle 1 or 0. 1 for loop music
- offset: start music offset
spawn Boss1
@script
void main()
{
void self = getlocalvar("self");
int Check = getglobalvar("Boss1");
if(Check==6){
killentity(self);
} else {
playmusic("data/music/boss.bor",1);
}
}
@end_script
coords 550 460 1
at 0
You can change music directly with music command in level text.
However if you have specific condition which must be met before music is changed, you'd need script like this:
This script is declared on boss spawn in metroidvania setting. When boss1 appears for the first time, Boss1 global variable is not set yet or simply put, boss music is played. After boss1 is defeated, Boss1 variable is set so when player returns to this room/level again, boss music won't be played and boss1 is removed.