Solved Looping playmusic Without Returning to Intros in Entities

Question that is answered or resolved.

maxman

Well-known member
I'm trying to loop music with playmusic in an entity similar to looping music in stages.

Code:
music		data/music/stg1-1.bor 122603.79

Code:
music  data/music/cody1.ogg 3074828.4
at              210

I'm trying to loop the song without going back to the intro. I know how to loop music in stages but how can I loop a song in that part for entities? Do I need to put very higher value in delay (with some more frames added in an animation) to make the music play longer without killing itself? Do I need to go with offset like this? I see offset is for starting music offset in stage. Dunno for entities. I thought it could loop without going back to the intro.

playmusic(path, loop, offset)

Code:
name      Randommusic
type      none

anim	follow1
@script
    if(frame==1){
      playmusic("data/music/bison.ogg", 1, 3991491);
    }
    if(frame==2){
      void self = getlocalvar("self");
      int r = rand()%30;

      if( r > 10 ){
        setidle(self, openborconstant("ANI_IDLE"));
      } else if( r < -10 ){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
      } else if( r > -10){
	changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
      }
    }
	@end_script	
	loop	1
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.gif
	delay	1000
	frame	data/chars/misc/empty.gif
	delay	1
	frame	data/chars/misc/empty.gif
		
anim	follow2
@script
    if(frame==1){
      playmusic("data/music/ryu.ogg", 1, 1992614.4);
    }
    if(frame==2){
      void self = getlocalvar("self");
      int r = rand()%30;

      if( r > 10 ){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
      } else if( r < -10 ){
        setidle(self, openborconstant("ANI_IDLE"));
      } else if( r > 10 ){
	changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
      }
    }
	@end_script	
	loop	1
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.gif
	delay	1000
	frame	data/chars/misc/empty.gif
	delay	1
	frame	data/chars/misc/empty.gif
		
anim	follow3
@script
    if(frame==1){
      playmusic("data/music/cody1.ogg", 1, 3074828.4);
    }
    if(frame==2){
      void self = getlocalvar("self");
      int r = rand()%30;

      if( r > 10 ){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
      } else if( r < -10 ){
        setidle(self, openborconstant("ANI_IDLE"));
      } else if( r > -10 ) {
	changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
      }
    }
	@end_script	
	loop	1
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.gif
	delay	17000
	frame	data/chars/misc/empty.gif
	delay	1
	frame	data/chars/misc/empty.gif
		
anim	idle
@script
    if(frame==1){
      playmusic("data/music/ken.ogg", 1, 4124628.9);
      //setmusicvolume(20,500);
      //setmusictempo(150);
    }
    if(frame==2){
      void self = getlocalvar("self");
      int r = rand()%30;

      if( r > 10 ){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
      } else if( r < -10 ){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
      } else if( r > -10 ){
	changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
      }
    }
	@end_script	
	loop	1
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.gif
   delay   16000 #delay 6000 is 1 minute; 100 centiseconds is 1 second;
	frame	data/chars/misc/empty.gif
	delay	1
	frame	data/chars/misc/empty.gif
		
#|edited by openBor Stats v 0.67

EDIT: Solved. I added offset for looping without going back to the intro.

Code:
anim idle
	offset	99 183
	delay	1
	frame	data/chars/misc/empty.gif
	@cmd playmusic "data/music/cody1.ogg" 1 3074828.4
	frame	data/chars/misc/empty.gif
 
I've never managed to get the loop points to work properly, it always seems to be slightly out a bit.  I'm sure it can work, but the few times I've needed it the time I had spent trying to get it right wasn't worth it.  The cues I get from the audio program are dead accurate but they don't work in openbor.    :-\

So I just cut the intro out as separate ogg then setup a basic entity to play the looped section once the intro ends.  Which took like 5minutes work.
 
Never mind. I was stupid for not checking with offset in playmusic before till I realized it now.

Example:
playmusic("data/music/Cody1.ogg", 1, 3074828.4);
 
Back
Top Bottom