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 Lightswitch with locals [SOLVED]
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#1
Lightswitch with locals [SOLVED]

I can switch the light on but not off.

Spoiler below!

void OnStart()
{
SetLocalVarInt("loc_light_living", 0);
}

void switch_living(string &in asEntity)
{
if(GetLocalVarInt("loc_light_living") == 0)
{
SetLampLit("gas_lamp_ceiling_1", true, true);
SetLampLit("gas_lamp_ceiling_2", true, true);

FadeLightTo("fade", 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.5f);

AddTimer("LocalValTimer", 0.1f,"living_val_on");
}

if(GetLocalVarInt("loc_light_living") == 1)
{
SetLampLit("gas_lamp_ceiling_1", false, true);
SetLampLit("gas_lamp_ceiling_2", false, true);

AddTimer("LocalValTimer", 0.1f,"living_val_off");
}
}

void LocalValTimer(string &in asTimer)
{
if(asTimer == "living_val_on")
{
SetLocalVarInt("loc_light_living", 1);
}
if(asTimer == "living_val_off")
{
SetLocalVarInt("loc_light_living", 0);
}
}


FIXED IT.

"What you think is irrelevant" - A character of our time

A Christmas Hunt
(This post was last modified: 01-23-2014, 10:48 PM by i3670.)
01-23-2014, 09:54 PM
Find
daortir Offline
Senior Member

Posts: 422
Threads: 9
Joined: Sep 2013
Reputation: 18
#2
RE: Lightswitch with locals

This thread existed a few days ago, here's dNALANGE's answer in case you don't know where to look : )

"I've fixed this issue, REALLY easy!
Do this :
Go to the modeleditor -> Look for your lamp -> Open it -> Settings -> User defined variables -> Make the lamp be a BUTTON.
There you go Wink
Smarty smart lange Wink
---
Be sure to NOT overwrite the Original lamp.
AND be sure to save the lamp into YOUR STORY!
Bet, almost everyone knows this, just tell this for people who are new to this."

There you go, no need to create any useless variable nightmare xD.

01-23-2014, 10:00 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#3
RE: Lightswitch with locals

mm yeah, you see these lamps are in the ceiling and it'd be more practical to have a lightswitch ergo the script.

"What you think is irrelevant" - A character of our time

A Christmas Hunt
01-23-2014, 10:03 PM
Find
daortir Offline
Senior Member

Posts: 422
Threads: 9
Joined: Sep 2013
Reputation: 18
#4
RE: Lightswitch with locals

(01-23-2014, 10:03 PM)i3670 Wrote: mm yeah, you see these lamps are in the ceiling and it'd be more practical to have a lightswitch ergo the script.

Misunderstood that : ) !
I don't see any scripting mistakes in your code, but if I am correct none of the amfp lamps could be turned off if it wasn't set as a button right ?

01-23-2014, 10:10 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#5
RE: Lightswitch with locals

You can't turn them off manually inside the game. You can however through script.

"What you think is irrelevant" - A character of our time

A Christmas Hunt
01-23-2014, 10:12 PM
Find
daortir Offline
Senior Member

Posts: 422
Threads: 9
Joined: Sep 2013
Reputation: 18
#6
RE: Lightswitch with locals

Oh well ^^. (Sorry for not knowing anything about those lamps I'm still not using amfp stuff).
Then it's a scripting mistake right ? I'm not seeing it so I'll just give my usual advice, add debug messages basically everywhere and you'll know where the issue is. You'll probably need some to check if the variables are taking the correct values, then simply some to know if your script lines coding the light going off are correctly scripted.

Good luck with that and sorry for not being helpful so far xD
The good point is that debug messages can't fail to show you where your mistake lies, so if you do it cautiously there is no way you'll not know what is going wrong :3.

(This post was last modified: 01-23-2014, 10:26 PM by daortir.)
01-23-2014, 10:25 PM
Find




Users browsing this thread: 4 Guest(s)