|
Why does this function not work?
#420430
03/25/13 21:51
03/25/13 21:51
|
Joined: Jan 2013
Posts: 63
Loremaster
OP
Junior Member
|
OP
Junior Member
Joined: Jan 2013
Posts: 63
|
function playMusic() {
if (event_type ==EVENT_SCAN && you==player) { //The Player entity has scanned me
if (media_playing(nMusicHandle) == 0) { //Only play me if there is no music
nMusicHandle = media_play(sMusicTitle, NULL, nMusicVol);
}
else {
showDialog("Music Handler in use."); //DEBUG CONDITION
}
}
}
It is supposed to start the function as soon as the player scans the object. If already a track is playing (handler > 0), none should be played. Actually it starts the track over and over again, playing it in dissonance as long as the player scans the object. I can only imagine I use the condition wrong, but that's what I ttok from the manual.
|
|
|
Re: Why does this function not work?
[Re: 3run]
#420435
03/25/13 22:41
03/25/13 22:41
|
Joined: Jan 2013
Posts: 63
Loremaster
OP
Junior Member
|
OP
Junior Member
Joined: Jan 2013
Posts: 63
|
I know that it meets the condition every time. Which it shouldn't. media_playing should return the current frame, therefore be >0 as soon as the title starts. But it isn't.
Last edited by Loremaster; 03/25/13 23:10.
|
|
|
Re: Why does this function not work?
[Re: MasterQ32]
#420441
03/26/13 01:29
03/26/13 01:29
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
How did you define nMusicHandle ?
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Why does this function not work?
[Re: Uhrwerk]
#420442
03/26/13 02:09
03/26/13 02:09
|
Joined: Jan 2013
Posts: 63
Loremaster
OP
Junior Member
|
OP
Junior Member
Joined: Jan 2013
Posts: 63
|
#define musType skill1
#define musID skill2
int nMusicVol = 100; //Must be handled by the Game-Settings later.
int nMusicHandle = 0; //Mediahandle for all things related to music.
STRING* sMusicTitle;
///////////////////////
//
//PICKING AND PLAYING THE MUSIC
//
///////////////////////
function playMusic() {
if (media_playing(nMusicHandle)==0) { //Only play me if there is no music
nMusicHandle = media_play(sMusicTitle, NULL, nMusicVol);
}
}
function pickMusic(){
if (event_type ==EVENT_SCAN && you==player) { //The Player entity has scanned me
switch(my.musID) { //musID-Skill determines, which song to play
case 1:
sMusicTitle = "Musik\\stealth2.mp3";
break;
case 2:
sMusicTitle = "Musik\\stealth1.mp3";
break;
case 3:
sMusicTitle = "Musik\\scene1.mp3";
break;
default: //Fallback: If something goes wrong, we play the most generic stealth
sMusicTitle = "Musik\\stealth1.mp3"; //music we have. Can't be too inappropriate.
}
playMusic();
}
}
// skill1: musType 0
// help: default 0 = Ambient, 1 = Scene, 2 = Action
// skill2: musID 1
// help: Refer to the tracklist I gave you
action triggerMusic() {
my.emask |= ENABLE_SCAN; //I will react when being scanned
my.event = pickMusic;
my.skill60 = 20; //me is some kind of trigger. me happy.
set (my,INVISIBLE);
set (my,PASSABLE);
}
|
|
|
Re: Why does this function not work?
[Re: Loremaster]
#420455
03/26/13 13:22
03/26/13 13:22
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
I'm glad I could help. ^^
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|