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
Switch a light on when you enter an area?
rallelol Offline
Member

Posts: 53
Threads: 11
Joined: Dec 2011
Reputation: 1
#1
Switch a light on when you enter an area?

Hello! I was just wondering how you get a light to turn on when you enter a certain area, and if it's possible.

I'm thinking of a regular "candle_floor" or something in the lampentity tab.

Thank you!
(This post was last modified: 01-12-2012, 06:06 PM by rallelol.)
01-12-2012, 05:11 PM
Find
Inurias Offline
Junior Member

Posts: 20
Threads: 0
Joined: Jan 2012
Reputation: 2
#2
RE: Switch a light on when you enter an area?

Detect Player entering ScriptArea:
void AddEntityCollideCallback(string& asParentName, string&  asChildName, string& asFunction, bool abDeleteOnCollide, int  alStates);

Calls a function when two entites collide.
Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)
alState: 1 = enter, -1 = leave

asParentName - internal name of main object
asChildName - internal name of object that collides with main object (asterix (*) NOT supported!)
asFunction - function to call
abDeleteOnCollide - determines whether the callback after it was called
alStates - 1 = only enter, -1 = only leave, 0 = both


Turn lamp on:
void SetLampLit(string& asName, bool abLit, bool abEffects);

asName - name of the lamp
abLit - true = on, false = off
abEffects - true = use effects, false = don't use effects when turning on/off


Example:
void OnStart()
{
    AddEntityCollideCallback("Player",  "LAMPAREA", "CollideLAMPAREA", true, 1); //Add the callback for the  player (calls "CollideLAMPAREA" when entering)
}

void CollideLAMPAREA(string &in asParent, string &in asChild, int alState)
{
    SetLampLit("MYLAMP", true, true); //Turn lamp on
}

Script functions for further information in the future: http://wiki.frictionalgames.com/hpl2/amn..._functions

-Inurias
01-12-2012, 05:42 PM
Find
rallelol Offline
Member

Posts: 53
Threads: 11
Joined: Dec 2011
Reputation: 1
#3
RE: Switch a light on when you enter an area?

(01-12-2012, 05:42 PM)Inurias Wrote: Detect Player entering ScriptArea:
void AddEntityCollideCallback(string& asParentName, string&  asChildName, string& asFunction, bool abDeleteOnCollide, int  alStates);

Calls a function when two entites collide.
Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)
alState: 1 = enter, -1 = leave

asParentName - internal name of main object
asChildName - internal name of object that collides with main object (asterix (*) NOT supported!)
asFunction - function to call
abDeleteOnCollide - determines whether the callback after it was called
alStates - 1 = only enter, -1 = only leave, 0 = both


Turn lamp on:
void SetLampLit(string& asName, bool abLit, bool abEffects);

asName - name of the lamp
abLit - true = on, false = off
abEffects - true = use effects, false = don't use effects when turning on/off


Example:
void OnStart()
{
    AddEntityCollideCallback("Player",  "LAMPAREA", "CollideLAMPAREA", true, 1); //Add the callback for the  player (calls "CollideLAMPAREA" when entering)
}

void CollideLAMPAREA(string &in asParent, string &in asChild, int alState)
{
    SetLampLit("MYLAMP", true, true); //Turn lamp on
}

Script functions for further information in the future: http://wiki.frictionalgames.com/hpl2/amn..._functions

-Inurias
I tried with
SetLightVisible(string& asLightName, bool abVisible);
first but it obviously didn't work.
Thank you though!

01-12-2012, 06:05 PM
Find
Khyrpa Offline
Senior Member

Posts: 638
Threads: 10
Joined: Apr 2011
Reputation: 24
#4
RE: Switch a light on when you enter an area?

eh...
SetLightVisible(string& asLightName, bool abVisible);
is for point lights, box lights and spot lights

SetLampLit
is for lamp entities

01-12-2012, 06:10 PM
Find
rallelol Offline
Member

Posts: 53
Threads: 11
Joined: Dec 2011
Reputation: 1
#5
RE: Switch a light on when you enter an area?

(01-12-2012, 06:10 PM)Khyrpa Wrote: eh...
SetLightVisible(string& asLightName, bool abVisible);
is for point lights, box lights and spot lights

SetLampLit
is for lamp entities
I know... well i know now ;d


01-12-2012, 06:16 PM
Find




Users browsing this thread: 1 Guest(s)