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 Lever Issues
daortir Offline
Senior Member

Posts: 422
Threads: 9
Joined: Sep 2013
Reputation: 18
#1
Lever Issues

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
Find
Lizard Offline
Member

Posts: 174
Threads: 23
Joined: Jul 2012
Reputation: 5
#2
RE: Lever Issues

(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

CURRENT PROJECT:
A Fathers Secret == Just started
(This post was last modified: 01-06-2014, 05:48 PM by Lizard.)
01-06-2014, 05:43 PM
Find
daortir Offline
Senior Member

Posts: 422
Threads: 9
Joined: Sep 2013
Reputation: 18
#3
RE: Lever Issues

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

01-07-2014, 01:28 PM
Find




Users browsing this thread: 1 Guest(s)