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
Script Help Light scripting
goodcap Offline
Member

Posts: 193
Threads: 112
Joined: Jun 2012
Reputation: 3
#1
Light scripting

Hello,

what I want is that you push a button and then a light turns on and you hear a voice. And after the voice is done talking the light turns off again. How do I do this?
07-11-2014, 04:35 PM
Find
Rapture Offline
Posting Freak

Posts: 1,078
Threads: 79
Joined: May 2011
Reputation: 30
#2
RE: Light scripting

Have you looked at the HPL2 wiki > Scripting Functions yet?

https://wiki.frictionalgames.com/hpl2/am..._functions
(This post was last modified: 07-11-2014, 05:23 PM by Rapture.)
07-11-2014, 05:23 PM
Find
goodcap Offline
Member

Posts: 193
Threads: 112
Joined: Jun 2012
Reputation: 3
#3
RE: Light scripting

I have. But i can't find the func that disables a light after the voice is done
07-11-2014, 06:01 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#4
RE: Light scripting

SetLightVisible( light_name, true/false );

If the light it's an entity, use SetEntityActive( entity_name, true/false );

If you want the light to turn off after a sound it's over, calculate the time and use a timer, for a 10 seconds delay use this:
AddTimer ( "light_name", 10, "TurnOffLight" );

This is the function the timer should call to turn off
void TurnOffLight ( string &in light )
{ SetLightVisible( light, false ); }

If you're using AddEffectVoice you can use SetEffectVoiceOverCallback to set a function after the voice is over.

(This post was last modified: 07-11-2014, 06:30 PM by Daemian.)
07-11-2014, 06:28 PM
Find
goodcap Offline
Member

Posts: 193
Threads: 112
Joined: Jun 2012
Reputation: 3
#5
RE: Light scripting

(07-11-2014, 06:28 PM)Amn Wrote: SetLightVisible( light_name, true/false );

If the light it's an entity, use SetEntityActive( entity_name, true/false );

If you want the light to turn off after a sound it's over, calculate the time and use a timer, for a 10 seconds delay use this:
AddTimer ( "light_name", 10, "TurnOffLight" );

This is the function the timer should call to turn off
void TurnOffLight ( string &in light )
{ SetLightVisible( light, false ); }

If you're using AddEffectVoice you can use SetEffectVoiceOverCallback to set a function after the voice is over.

I tried the script without the voice. This is my script:

void OnStart()
{
SetEntityCallbackFunc("knop", "PlayVoice");
}

void PlayVoice(string &in asEntity, int alState)
{
SetLightVisible( "roomlight", true );
AddTimer ( "roomlight", 10, "TurnOffLight" );
{
void TurnOffLight ( string &in light )
{
SetLightVisible( "roomlight", false );
}
}

------------------------

It tells me: ''unexpected end of file'' when I test the level. What did I do wrong?
07-11-2014, 06:41 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#6
RE: Light scripting

Extra } at the end.

07-11-2014, 06:49 PM
Find
goodcap Offline
Member

Posts: 193
Threads: 112
Joined: Jun 2012
Reputation: 3
#7
RE: Light scripting

(07-11-2014, 06:49 PM)Amn Wrote: Extra } at the end.

I did that, now it says: Expected {
07-11-2014, 06:50 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#8
RE: Light scripting

And you can remove the light name in the arguments if you're not going to use it.

See, this timer AddTimer ( "roomlight", 10, "TurnOffLight" );
Is giving the name of your light (roomlight) to the function it's going to call (TurnOffLight function)

Below, the function TurnOffLight, it has the name of your light in a variable named light. You can refer to that instead of typing in the name of the light.

void TurnOffLight ( string &in light )
{ SetLightVisible( light, false );


But whatever. As long as it works, it's ok.

You can copy&paste this

void OnStart()
{
SetEntityCallbackFunc("knop", "PlayVoice");
}

void PlayVoice(string &in asEntity, int alState)
{
SetLightVisible( "roomlight", true );
AddTimer ( "roomlight", 10, "TurnOffLight" );
}

void TurnOffLight ( string &in light )
{
SetLightVisible( light, false );
}

(This post was last modified: 07-11-2014, 07:05 PM by Daemian.)
07-11-2014, 06:59 PM
Find




Users browsing this thread: 1 Guest(s)