Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Imhotep), 567 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Why does this function not work? #420430
03/25/13 21:51
03/25/13 21:51
Joined: Jan 2013
Posts: 63
Loremaster Offline OP
Junior Member
Loremaster  Offline OP
Junior Member

Joined: Jan 2013
Posts: 63
Code:
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: Loremaster] #420431
03/25/13 22:07
03/25/13 22:07
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Try to insert beep(); before and after each comparision, to find which one doesn't work.. That will help you to find out the problem yourself laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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 Offline OP
Junior Member
Loremaster  Offline 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: Loremaster] #420439
03/26/13 01:22
03/26/13 01:22
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
try to use some kind of "music manager".
this doesn't have to be more than one function which just fades between different songs and your event just has to set a variable to the correct music id.


Visit my site: www.masterq32.de
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 Offline
Expert
Uhrwerk  Offline
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 Offline OP
Junior Member
Loremaster  Offline OP
Junior Member

Joined: Jan 2013
Posts: 63
Code:
#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] #420443
03/26/13 02:17
03/26/13 02:17
Joined: Jan 2013
Posts: 63
Loremaster Offline OP
Junior Member
Loremaster  Offline OP
Junior Member

Joined: Jan 2013
Posts: 63
Saw it myself.

int. redeclared to var and voilà. That was a VERY insigthful question, Uhrwerk. Thank you once again.

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 Offline
Expert
Uhrwerk  Offline
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...

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1