Torches on tilesets will remain on, regardless of scripting. This is because the RecomputeStaticLighting script command will not reset the ambient lighting for that tile, even if you turn the tileset torches off via a script, they stay on. You would need to turn off any tileset torches and place your own.
Campfires are the same if it's a tileset campfire.
Placeable campfires or torches can be turned off or on by using the script below. Again, make sure the placeable has its STATIC box UNCHECKED. The script is the same as the one above, I just inserted removal or additions of the placeables ACTIVATED or DEACTIVATED status.
void main()
{
if (GetIsNight() && GetLocalInt(OBJECT_SELF,"lightme")==0)
{
SetLocalInt(OBJECT_SELF,"lightme",1);
PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
effect light = EffectVisualEffect( VFX_DUR_LIGHT_ORANGE_20 );
//effect light = EffectVisualEffect( VFX_DUR_LIGHT_BLUE_5 );
ApplyEffectToObject( DURATION_TYPE_PERMANENT, light, OBJECT_SELF, 6.0 );
RecomputeStaticLighting(GetArea(OBJECT_SELF));
}
else if (GetIsDay() && GetLocalInt(OBJECT_SELF,"lightme")==1)
{
SetLocalInt(OBJECT_SELF,"lightme",0);
effect eLoop;
object oGlowingThing = OBJECT_SELF;
eLoop = GetFirstEffect ( oGlowingThing );
while ( GetIsEffectValid ( eLoop ) )
{
int iType = GetEffectType ( eLoop );
if ( iType == EFFECT_TYPE_VISUALEFFECT )
{
RemoveEffect ( oGlowingThing, eLoop );
PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
}
eLoop = GetNextEffect ( oGlowingThing );
}
RecomputeStaticLighting(GetArea(oGlowingThing));
}
}
Due take note, when the placeable campfire is DEACTIVATED, the glow of the fire still remains, even though the fire itself is no longer flickering. This is the same issue I noted regarding the placeable lanterns.
The torches, found under - Placeables - Standard - Building Adornments - Torch Bracket - will work fine when DEACTIVATED. They do not retain their glow as the placeable lanterns and campfires do.
FP!
Modifié par Fester Pot, 28 octobre 2011 - 05:47 .