Frictional Games Forum (read-only)
[SCRIPT] Lever Issues - 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: [SCRIPT] Lever Issues (/thread-24305.html)



Lever Issues - daortir - 01-06-2014

Hello there !
Simple script issue : I suck at using levers, so basically, how can I make a lever stuck in a position, then be movable again when an event occured, and call a function when it's used ?

As I said, I'm really terrible with scripting those lever/wheels/thinggies, I'd love to get some help so I understand once and for all how it works ; D.


RE: Lever Issues - Lizard - 01-06-2014

(01-06-2014, 01:56 PM)daortir Wrote: Hello there !
Simple script issue : I suck at using levers, so basically, how can I make a lever stuck in a position, then be movable again when an event occured, and call a function when it's used ?

As I said, I'm really terrible with scripting those lever/wheels/thinggies, I'd love to get some help so I understand once and for all how it works ; D.

SetLeverStuckState is used to make the lever go stuck

SetEntityConnectionStateChangeCallback is used to call a function when the lever change state

lever state can be 1, -1 and 0. 0 is the middle (default state), 1 is down and -1 is up

example:

void OnStart()
{
SetEntityConnectionStateChangeCallback("lever_name", "function (function to call)");
AddEntityCollideCallback"Player", "Area", "function2", 1, true);
}

void function(string &in asEntity, int alState)
{
if (alState == 1)
{
SetLeverStuckState("Lever_name", 1 (state of the lever to get stuck in), false); //
GivePlayerDamage(2, "Claws", false, false);
}
}
Now when you pull the lever down it will get stuck there and the player takes 2 damage

void function2(string &in asParent, string &in asChild, int alState)
{
SetLeverStuckState("lever_name", 0, false);
}
using 0 in SetLeverStuckState will make the lever go unstuck


RE: Lever Issues - daortir - 01-07-2014

Thanks a lot for the great explanations < 3. I will make good use of it as soon as I feel brave enough to script again : D