Frictional Games Forum (read-only)
Camera flash script - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Camera flash script (/thread-22772.html)



Camera flash script - JonnyAnomaly - 09-08-2013

I'm trying to make a script for a camera flash as a lantern - I have it working except for the script. The camera is just a lantern with a spotlight, with its fade in and out set to 0, so its instant. Preferably I'd like to have the lantern switch itself off after 0.1 seconds of being turned on. I've being trying to use a script like this, but its not working as I would expect...

void OnStart()

{
if( !GetLanternActive()==true)
{
AddTimer("", 0.1, "LanternOff");
}

}

void LanternOff(string &in asTimer)
{
SetLanternDisabled(true);
AddTimer("", 5.0, "LanternOn");
}

void LanternOn(string &in asTimer)
{

if( !GetLanternActive()==false)
{
SetLanternDisabled(false);
}

}

I get the feeling it should be really simple, but I'm still terrible at scripting Dodgy


RE: Camera flash script - Kreekakon - 09-08-2013

Here's how to fix it:

Move this...
Code:
if( !GetLanternActive()==true)

        {

        AddTimer("", 0.1, "LanternOff");

        }

...from OnStart to a new timer function of its own which starts ticking once the map starts. Make the timer repeat itself very quickly, and make it keep renewing itself.

This is so that you can constantly check to see if your lantern is on, or not.


RE: Camera flash script - PutraenusAlivius - 09-08-2013

PHP Code:
void OnStart()
    
    {
        if(
GetLanternActive() != true)
        {
        
AddTimer(""0.1f"LanternOff");
        }
            
    }
    
    
void LanternOff(string &in asTimer)
     {
     
SetLanternDisabled(true);
     
AddTimer(""5.0"LanternOn");
     }
    
    
void LanternOn(string &in asTimer)
     {
     
     if(
GetLanternActive()  != false)
        {
        
SetLanternDisabled(false);
        }

     } 

Fixed.

- You forgot to put an f at the first AddTimer.
- Pretty sure it's != not !*parameter* or !==

EDIT: Ninja'd. Oh well.


RE: Camera flash script - JonnyAnomaly - 09-08-2013

Thanks for the help, guys!

Edit - Would you be able to give an example of how that script would look? I tried to make the changes but its not working. Once I see it complete I'm sure I will understand it better.


RE: Camera flash script - Apfel - 09-08-2013

I would do something like this:


void OnStart()
{
SetLanternLitCallback("camera_flash");
}

void camera_flash(bool abLit)
{
AddTimer("", 0.1f, "LanternOff");
}

void LanternOff(string &in asTimer)
{
SetLanternDisabled(true);
}



Maybe this works, but I haven't tested it.


RE: Camera flash script - JonnyAnomaly - 09-08-2013

Thanks Apfel! I got it to work properly by adding:


void LanternOff(string &in asTimer)
{
SetLanternDisabled(true);
AddTimer("", 5.0f, "LanternOn");
}

void LanternOn(string &in asTimer)
{
SetLanternDisabled(false);
}

Never knew about that lanternLit callback Smile