Frictional Games Forum (read-only)

Full Version: Changing Lantern Spotlight color mid game
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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.
It must work:
SetLightVisible("PlayerHands_SpotLight_1", false);
I can't get it to work Sad

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)Reminiscity Wrote: [ -> ]I can't get it to work Sad

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.

Code:
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.
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]

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.
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 Sad
Simply use SetLanternLitCallback() to make sure all genetics are injected properly when they pull it out.
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);

}