Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Camera flash script
JonnyAnomaly Offline
Member

Posts: 179
Threads: 20
Joined: Nov 2012
Reputation: 14
#1
Camera flash script

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
09-08-2013, 02:38 PM
Find
Kreekakon Offline
Pick a god and pray!

Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation: 124
#2
RE: Camera flash script

Here's how to fix it:

Move this...
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.

[Image: Tv0YgQb.gif]
Image by BandyGrass
09-08-2013, 02:43 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#3
RE: Camera flash script

PHP Code: (Select All)
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.

"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 09-08-2013, 02:47 PM by PutraenusAlivius.)
09-08-2013, 02:46 PM
Find
JonnyAnomaly Offline
Member

Posts: 179
Threads: 20
Joined: Nov 2012
Reputation: 14
#4
RE: Camera flash script

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.
(This post was last modified: 09-08-2013, 04:08 PM by JonnyAnomaly.)
09-08-2013, 03:18 PM
Find
Apfel Offline
Junior Member

Posts: 19
Threads: 3
Joined: Jun 2011
Reputation: 1
#5
RE: Camera flash script

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.
09-08-2013, 04:47 PM
Find
JonnyAnomaly Offline
Member

Posts: 179
Threads: 20
Joined: Nov 2012
Reputation: 14
#6
RE: Camera flash script

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
(This post was last modified: 09-08-2013, 05:44 PM by JonnyAnomaly.)
09-08-2013, 05:44 PM
Find




Users browsing this thread: 1 Guest(s)