| 
		
	
		| Reminiscity   Member
 
 Posts: 81
 Threads: 16
 Joined: Jan 2013
 Reputation: 
2
 | 
			| Changing Lantern Spotlight color mid game 
 
				HELLO FRIENDS!
 Is it possible to change lantern spotlight color mid game? Or deactivate one spotlight and activate another?
 
 I bet the answer is no but I would kill myself with a spoon if I found out it was possible after I released my mod.
 
 If I remember correctly I saw at least two spotlights in the AMFP lantern entity file one of which was deactivated. I think it was used to create the flickering when pigs were nearby.
 
 |  |  
	| 03-22-2016, 07:44 PM |  |  
	
		| Mudbill   Muderator
 
 Posts: 3,881
 Threads: 59
 Joined: Apr 2013
 Reputation: 
179
 | 
			| RE: Changing Lantern Spotlight color mid game 
 
				It MIGHT be possible. You should try using, for example, SetLightVisible("lantern_SpotLight_1", false);. Basically input the light name like [EntityName]_[LightName]. That should fetch the light name from within that entity. Make sure both match.
 As for color, try using FadeLightTo() instead.
 
 |  |  
	| 03-22-2016, 09:49 PM |  |  
	
		| Fatalist   Member
 
 Posts: 122
 Threads: 8
 Joined: Dec 2012
 Reputation: 
8
 | 
			| RE: Changing Lantern Spotlight color mid game 
 
				It must work:SetLightVisible("PlayerHands_SpotLight_1", false);
 
 |  |  
	| 03-26-2016, 04:39 AM |  |  
	
		| Reminiscity   Member
 
 Posts: 81
 Threads: 16
 Joined: Jan 2013
 Reputation: 
2
 | 
			| RE: Changing Lantern Spotlight color mid game 
 
				I can't get it to work    
The lantern entity name is "lantern_mandus". I find this method a bit wierd because how would the engine know what is the entity name and what is the spotlight name when its only separated with an underscore? And in this case the entity name has an underscore in it which makes things even wierder.
 
SetLightVisible("lantern_mandus_SpotLight_2", false);
			
 |  |  
	| 03-26-2016, 02:49 PM |  |  
	
		| Romulator   Not Tech Support ;-)
 
 Posts: 3,628
 Threads: 63
 Joined: Jan 2013
 Reputation: 
195
 | 
			| RE: Changing Lantern Spotlight color mid game 
 
				 (03-26-2016, 02:49 PM)Reminiscity Wrote:  I can't get it to work  
 The lantern entity name is "lantern_mandus". I find this method a bit wierd because how would the engine know what is the entity name and what is the spotlight name when its only separated with an underscore? And in this case the entity name has an underscore in it which makes things even wierder.
 
 SetLightVisible("lantern_mandus_SpotLight_2", false);
 
Do what Fatalist wrote above.
 SetLightVisible("PlayerHands_SpotLight_1", false);
Be sure to check the Model Editor to see which spotlight you want to fade, and make sure it is the correct spotlight you're referencing.
			 
 Discord: Romulator#0001
![[Image: 3f6f01a904.png]](https://puu.sh/zOxJg/3f6f01a904.png) |  |  
	| 03-26-2016, 03:34 PM |  |  
	
		| Mudbill   Muderator
 
 Posts: 3,881
 Threads: 59
 Joined: Apr 2013
 Reputation: 
179
 | 
			| RE: Changing Lantern Spotlight color mid game 
 
				Yes, the entity name must be the lantern entity that is held, not the item you pick up. Is it called PlayerHands though? I thought that was the entity name of the hand entity, which doesn't hold the light. 
The entity is within the /models folder. The default entity file is named hand_lantern.ent and the MFP one is lantern_mandus.ent. To me, that would make sense to put mandus_lantern_SpotLight_2 (SpotLight_1 is ambient, whereas SpotLight_2 is the beam).
 ![[Image: 6XN65u4.png]](http://i.imgur.com/6XN65u4.png)  
Try to see if you can use this method for changing light properties to a simple entity, like a torch. It should work. The hand objects might be a bit different though. I've never done it myself.
 
Edit: Hang on a sec. You named your script to use "lantern_mandus..." not "mandus_lantern...". That might be the issue.
			
 
				
(This post was last modified: 03-26-2016, 06:03 PM by Mudbill.)
 |  |  
	| 03-26-2016, 06:00 PM |  |  
	
		| Reminiscity   Member
 
 Posts: 81
 Threads: 16
 Joined: Jan 2013
 Reputation: 
2
 | 
			| RE: Changing Lantern Spotlight color mid game 
 
				SetLightVisible("PlayerHands_SpotLight_1", false); 
IT WORKS!!!! I WROTE THE WRONG SPOTLIGHT NAME xD There was a hidden spotlight inside the lantern model.
 
This is so awesome. Thank you all for your help!
 
 
There's one problem tho. When you lower the lantern and then use it again the color of the lights resets to default values   
 
				
(This post was last modified: 03-26-2016, 06:26 PM by Reminiscity.)
 |  |  
	| 03-26-2016, 06:19 PM |  |  
	
		| Mudbill   Muderator
 
 Posts: 3,881
 Threads: 59
 Joined: Apr 2013
 Reputation: 
179
 | 
			| RE: Changing Lantern Spotlight color mid game 
 
				Simply use SetLanternLitCallback() to make sure all genetics are injected properly when they pull it out.
			 
 |  |  
	| 03-26-2016, 08:09 PM |  |  
	
		| Reminiscity   Member
 
 Posts: 81
 Threads: 16
 Joined: Jan 2013
 Reputation: 
2
 | 
			| RE: Changing Lantern Spotlight color mid game 
 
				Managed to solve this. This is what I had to do.
 void OnStart()
 {
 
 SetLanternLitCallback("lanternColor");
 
 }
 
 void lanternColor(bool abLit)
 {
 
 AddTimer("lanternTimer", 0.3f, "changeLanternColor");
 
 }
 
 void changeLanternColor(string &in asTimer){
 
 FadeLightTo("PlayerHands_SpotLight_1", 0.1, 0.35, 0.5, 0.7, -1, 0);
 FadeLightTo("PlayerHands_SpotLight_2", 0.1, 0.35, 0.5, 0.7, -1, 0);
 FadeLightTo("PlayerHands_PointLight_1", 0.1, 0.35, 0.5, 0.5, -1, 0);
 
 }
 
 |  |  
	| 03-26-2016, 08:26 PM |  |  |