iLucian 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 22 
	Threads: 8 
	Joined: Jun 2013
	
 Reputation: 
0
		
	 | 
	
		
			
Help - Play Music when I touch an object 
			 
			
				Is there a way to play music when i touch an object? Like, can i pick up an item and then once i pick it up music plays? If so, then can someone plz help me! Thx!
			 
			
			
 
Wherever there is Light, Darkness has already gotten there first. 
			
		 |  
	 
 | 
 
	| 07-10-2013, 03:20 PM  | 
	
		
	 | 
 
 
	
		
		Zatchie 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 26 
	Threads: 2 
	Joined: Jul 2013
	
 Reputation: 
3
		
	 | 
	
		
			
RE: Help - Play Music when I touch an object 
			 
			
				I don't know the script for it but I do know somewhere in the game where you touch a pig it squeals. try finding that map and look at HPS file for it.
			 
			
			
 
			
		 |  
	 
 | 
 
	| 07-10-2013, 03:45 PM  | 
	
		
	 | 
 
 
	
		
		Artyom 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 370 
	Threads: 27 
	Joined: Jul 2012
	
 Reputation: 
11
		
	 | 
	
		
			
RE: Help - Play Music when I touch an object 
			 
			
				Check the wiki, you can find all codes there.
			 
			
			
 
			
		 |  
	 
 | 
 
	| 07-10-2013, 04:22 PM  | 
	
		
	 | 
 
 
	
		
		The chaser 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 2,486 
	Threads: 76 
	Joined: Jun 2012
	
 Reputation: 
113
		
	 | 
	
		
			
RE: Help - Play Music when I touch an object 
			 
			
				void OnStart() 
{  
SetEntityCallbackFunc("item", "OnPickup"); 
}
 
void OnPickup(string &in asEntity, string &in type) 
{ 
PlayMusic("music.ogg", false, 1, 1, 1, false); 
}
 
Source script from here:
 http://wiki.frictionalgames.com/hpl2/tut...n_entities
			 
			
			
 
                              THE OTHERWORLD (WIP) 
 
Aculy iz dolan.  
			
		 |  
	 
 | 
 
	| 07-10-2013, 07:15 PM  | 
	
		
	 | 
 
 
	
		
		iLucian 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 22 
	Threads: 8 
	Joined: Jun 2013
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Help - Play Music when I touch an object 
			 
			
				 (07-10-2013, 07:15 PM)The chaser Wrote:  void OnStart() 
{  
SetEntityCallbackFunc("item", "OnPickup"); 
} 
 
void OnPickup(string &in asEntity, string &in type) 
{ 
PlayMusic("music.ogg", false, 1, 1, 1, false); 
} 
 
Source script from here: 
 
http://wiki.frictionalgames.com/hpl2/tut...n_entities 
I dont know why but this isnt working for me   
-EDIT- 
ok so i changed the SetEntityCallbackFunc to SetEntityPlayerInteractCallback and entered the Syntax but for some reason the music wont stop looping! :O Help plz!!
			  
			
			
 
Wherever there is Light, Darkness has already gotten there first. 
			
				
(This post was last modified: 07-11-2013, 04:50 AM by iLucian.)
 
				
			 
		 |  
	 
 | 
 
	| 07-11-2013, 12:16 AM  | 
	
		
	 | 
 
 
	
		
		7heDubz 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 1,329 
	Threads: 40 
	Joined: Feb 2013
	
 Reputation: 
41
		
	 | 
	
		
			
RE: Help - Play Music when I touch an object 
			 
			
				 (07-11-2013, 12:16 AM)iLucian Wrote:   (07-10-2013, 07:15 PM)The chaser Wrote:  void OnStart() 
{  
SetEntityCallbackFunc("item", "OnPickup"); 
} 
 
void OnPickup(string &in asEntity, string &in type) 
{ 
PlayMusic("music.ogg", false, 1, 1, 1, false); 
} 
 
Source script from here: 
 
http://wiki.frictionalgames.com/hpl2/tut...n_entities  
I dont know why but this isnt working for me   
You have to have the item in your map named "item" (no quotations)
 
Do you know the basics of coding?
			  
			
			
 
			
		 |  
	 
 | 
 
	| 07-11-2013, 12:47 AM  | 
	
		
	 | 
 
 
	
		
		iLucian 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 22 
	Threads: 8 
	Joined: Jun 2013
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Help - Play Music when I touch an object 
			 
			
				 (07-11-2013, 12:47 AM)WIWWM Wrote:   (07-11-2013, 12:16 AM)iLucian Wrote:   (07-10-2013, 07:15 PM)The chaser Wrote:  void OnStart() 
{  
SetEntityCallbackFunc("item", "OnPickup"); 
} 
 
void OnPickup(string &in asEntity, string &in type) 
{ 
PlayMusic("music.ogg", false, 1, 1, 1, false); 
} 
 
Source script from here: 
 
http://wiki.frictionalgames.com/hpl2/tut...n_entities  
I dont know why but this isnt working for me    
You have to have the item in your map named "item" (no quotations) 
 
Do you know the basics of coding? 
-_- yes, instead of item i put in the name of the item. Instead of changing the name of the item to "item" i just put in the name of the item already.
			  
			
			
 
Wherever there is Light, Darkness has already gotten there first. 
			
		 |  
	 
 | 
 
	| 07-11-2013, 04:06 AM  | 
	
		
	 | 
 
 
	
		
		The chaser 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 2,486 
	Threads: 76 
	Joined: Jun 2012
	
 Reputation: 
113
		
	 | 
	
		
			
RE: Help - Play Music when I touch an object 
			 
			
				What item are you using? An Item is something you can pick up, an entity is something you can grab and interact with.
			 
			
			
 
                              THE OTHERWORLD (WIP) 
 
Aculy iz dolan.  
			
		 |  
	 
 | 
 
	| 07-11-2013, 02:21 PM  | 
	
		
	 | 
 
 
	
		
		iLucian 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 22 
	Threads: 8 
	Joined: Jun 2013
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Help - Play Music when I touch an object 
			 
			
				 (07-11-2013, 02:21 PM)The chaser Wrote:  What item are you using? An Item is something you can pick up, an entity is something you can grab and interact with. 
i am using a violin
			  
			
			
 
Wherever there is Light, Darkness has already gotten there first. 
			
		 |  
	 
 | 
 
	| 07-11-2013, 06:14 PM  | 
	
		
	 | 
 
 
	
		
		The chaser 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 2,486 
	Threads: 76 
	Joined: Jun 2012
	
 Reputation: 
113
		
	 | 
	
		
			
RE: Help - Play Music when I touch an object 
			 
			
				Then you are using the wrong code. The violin isn't an item, is an entity. To make that work, simply put this anywhere in your script, but not in void OnStart(). Put this:  
 
void Touch(string &in asEntity) 
{ 
PlayMusic("music.ogg", false, 1, 1, 1, false); 
} 
 
 
 
Now, select the violin and go to the entity panel. Go down, where it says "PlayerInteractCallback" and put "Touch". Now it should work.
			 
			
			
 
                              THE OTHERWORLD (WIP) 
 
Aculy iz dolan.  
			
		 |  
	 
 | 
 
	| 07-11-2013, 07:32 PM  | 
	
		
	 | 
 
 
	 
 |