Frictional Games Forum (read-only)

Full Version: Lever Issues
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
(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
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