3 registered members (TipmyPip, AndrewAMD, dBc),
18,430
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Play wav file
[Re: Lawrence]
#122785
04/10/07 19:58
04/10/07 19:58
|
Anonymous
Unregistered
|
Anonymous
Unregistered
|
Code:
sound snd_hello = <hello_player.wav>; // your wav (adjust)
action statue { var lv_snd_dist = 100; // 100 quants for play (adjust) var lv_snd_flag = off; // sound played
// wait for player... while(player==null){wait(1);}
// statue loop while(1){ // play when approaching if(vec_dist(player.x,my.x)<lv_snd_dist && lv_snd_flag==off){ snd_play(snd_hello, 100, 0); // play the sound lv_snd_flag=on; // play not again until player is gone... }else{ lv_snd_flag=off; // ready to play again... } wait(1); } }
or if it should loop... [EDIT] Code:
sound snd_hello = <hello_player.wav>; // your wav (adjust)
action statue { var lv_snd_dist = 100; // 100 quants for play (adjust) var lv_snd_hdl; // sound handle
// wait for player... while(player==null){wait(1);}
// statue loop while(1){ // play when approaching if(vec_dist(player.x,my.x)<lv_snd_dist && !snd_playing(lv_snd_hdl)){ lv_snd_hdl=snd_loop(snd_hello, 100, 0); // play the sound }
// stop loop if(vec_dist(player.x,my.x)>lv_snd_dist && snd_playing(lv_snd_hdl)){ snd_stop(lv_snd_hdl); } wait(1); } }
[/EDIT] not tested but should work...  mercuryus
Last edited by mercuryus; 04/10/07 20:05.
|
|
|
Re: Play wav file
[Re: Lawrence]
#122789
04/11/07 17:39
04/11/07 17:39
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
The my pointer automaticly refers to the entity which uses it. Imagine a bird (dumb example I know), when he is born he instantly knows who he is. (well kind of) But when the engine loads the level it might happen that the statue entity is created _before_ the player and thus does its action start to run earlier. Now on the first frame cycle there might be no player, so trying to access the player pointer (which is not set yet) will maybe create an "empty pointer error" (thats because that pointer is empty  ) Hope this explains the thing a bit, still I have no idea why the code does not work for you. - Do you have an entity which call itself "player" ?
|
|
|
Re: Play wav file
[Re: Lawrence]
#122791
04/11/07 17:50
04/11/07 17:50
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
Ok .. no the problem is actually that there will be no player pointer. So your code will never enter that "real" while loop. It will wait forever  I'm not sure but the pointer plbiped01 should refer to your player model: Code:
sound snd_hello = <hello_player.wav>; // your wav (adjust)
action statue { var lv_snd_dist = 100; // 100 quants for play (adjust) var lv_snd_hdl; // sound handle
// wait for player... while(plbiped01==null){wait(1);}
// statue loop while(1){ // play when approaching if(vec_dist(plbiped01.x,my.x)<lv_snd_dist && !snd_playing(lv_snd_hdl)){ lv_snd_hdl=snd_loop(snd_hello, 100, 0); // play the sound }
// stop loop if(vec_dist(plbiped01.x,my.x)>lv_snd_dist && snd_playing(lv_snd_hdl)){ snd_stop(lv_snd_hdl); } wait(1); } }
Not sure though, as I have never worked with the A6 templates. EDIT: It might also be just PLBIPED
Last edited by Thunder; 04/11/07 17:56.
|
|
|
|