Frictional Games Forum (read-only)
Lever Function [solved] - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Lever Function [solved] (/thread-6273.html)



Lever Function [solved] - Axe to the D - 01-18-2011

Hi all

I have the following problem. I want to make a lever open a door. I took a look at the script functions in this forum and found one.
After changing it looks like this:

// Secret Lever Function
void OnLeverStateChange("lever_01", 0)
{
SetSwingDoorLocked("door_hidden", false, true);
PlaySoundAtEntity("", "unlock_door", "door_hidden", 0, false);
}

But as I want to start the map - Fatal Error

Can anybody help me? Whats wrong with that function?


RE: Lever Function - Som1Lse - 01-18-2011

Your function definition is wrong.
Write this:
void OnLeverStateChange(string &in asName, int alState)
Instead of this:
void OnLeverStateChange("lever_01", 0)


RE: Lever Function - Axe to the D - 01-18-2011

Thank you very much.
But one more question. How does the game know that i mean my "lever_01"? It isn't defined anywhere, isn't it?


RE: Lever Function - Axe to the D - 01-18-2011

Does anyone know the solution?
At least the game doesn't crash anymore but the lever is still not working. The door doesn't open.


RE: Lever Function - Andross - 01-18-2011

You have to set up the actual callback. It should be this one, not sure:
Code:
void SetEntityConnectionStateChangeCallback(string& asName, string& asCallback);
asName would be your "lever_01",
asCallback your callback function "OnLeverStateChange".


RE: Lever Function - Axe to the D - 01-18-2011

Holy s*** it works now! Thank you sir Big Grin