Frictional Games Forum (read-only)
Change lever function? - 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: Change lever function? (/thread-21583.html)



Change lever function? - Storfigge - 05-23-2013

I wonder if it's possible to change the function of a lever? What I want is that the first time you use the lever you end up in one map but when you use the same lever a second time I want it to move to another map.

You're suppose to go down an elevator and the first time it leads to a dream, after the dream you end up in a dungeon and from this map you can take the elevator back to the first map. Once your back in the first map you can again if you missed something take the elevator, this time the dream wont happen so you just return to the dungeons, hope it's not confusing :S

My original idea was that I could SetEntityActive False on the first lever and SetEntityActive True on another lever that will lead to the dungeons. But I wonder if there is an easier way.


RE: Change lever function? - PutraenusAlivius - 05-23-2013

You can use local var int's.
Code:
void OnStart()
{
SetEntityConnectionStateChangeCallback("LeverName", "ElevatorUse");
SetLocalVarInt("Dream", 1);
}

void ElevatorUse(string &in asEntity, int alState)
{
if(GetLocalVarInt("Dream") == 1) //Dream occur!
{
ChangeMap("MapName", "PlayerStartAreaInTheMap", "SoundPlayedWhenTheChangeOccurs", "SoundPlayedWhenNewMapIsLoaded");
}

else //Dream over. I'm gonna wait for Tomato Cat to fix this.
{
ChangeMap("MapName", "PlayerStartAreaInTheMap", "SoundPlayedWhenTheChangeOccurs", "SoundPlayedWhenNewMapIsLoaded");
}
}



RE: Change lever function? - Bridge - 05-23-2013

(05-23-2013, 04:14 PM)JustAnotherPlayer Wrote: You can use local var int's.
Code:
void OnStart()
{
SetEntityConnectionStateChangeCallback("LeverName", "ElevatorUse");
SetLocalVarInt("Dream", 1);
}

void ElevatorUse(string &in asEntity, int alState)
{
if(GetLocalVarInt("Dream") == 1) //Dream occur!
{
ChangeMap("MapName", "PlayerStartAreaInTheMap", "SoundPlayedWhenTheChangeOccurs", "SoundPlayedWhenNewMapIsLoaded");
}

else //Dream over. I'm gonna wait for Tomato Cat to fix this.
{
ChangeMap("MapName", "PlayerStartAreaInTheMap", "SoundPlayedWhenTheChangeOccurs", "SoundPlayedWhenNewMapIsLoaded");
}
}

In case you didn't know, int is short for integer. They are not normally (or ever, I'd say) referred to as "ints".


RE: Change lever function? - Tomato Cat - 05-23-2013

(05-23-2013, 04:14 PM)JustAnotherPlayer Wrote:
Code:
else //Dream over. I'm gonna wait for Tomato Cat to fix this.
{

I *suppose* you could use an else statement. Unless you wanted states 0 and -1 to do something specific.