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 Making a barrel controlled by levers
Yrasin Offline
Junior Member

Posts: 1
Threads: 1
Joined: Jan 2012
Reputation: 0
#1
Making a barrel controlled by levers

Hi!

I have an idea of two levers controlling one small barrel using propimpulse. I have the script for controlling it but the problem is that I want a repeating script, like "as long as i hold down the lever it should go down. And not just go down using one propimpulse for each time i press down the lever. I hope you can understand and help me out on this one.

void OnStart()

{
SetEntityConnectionStateChangeCallback("leverupdown", "movebarrel1");
SetEntityConnectionStateChangeCallback("leverleverleftright", "movebarrel2");
}


void movebarrel2(string &in asEntity, int alState)
{
if (alState == 1)
{
AddPropImpulse("barrel", 1.5, 0, 0, "world");
AddTimer("", 0.2f, "repeatmovebarrel2");
}

if (alState == -1)
{
AddPropImpulse("barrel", -1.5, 0, 0, "world");
AddTimer("", 0.2f, "repeatmovebarrel2");
}
}

void repeatmovebarrel2(string &in asTimer, int alState)
{
GetLeverState("leverleverleftright");
{
if (alState == 1)
{
AddPropImpulse("barrel", 1.5, 0, 0, "world");
AddTimer("", 0.2f, "repeatmovebarrel2");
}

if (alState == -1)
{
AddPropImpulse("barrel", -1.5, 0, 0, "world");
AddTimer("", 0.2f, "repeatmovebarrel2");
}
}
}

void movebarrel1(string &in asEntity, int alState)
{
if (alState == 1)
{
AddPropImpulse("barrel", 0, 0, 1.5, "world");
AddTimer("", 0.2f, "repeatmovebarrel1");
}

if (alState == -1)
{
AddPropImpulse("barrel", 0, 0, -1.5, "world");
AddTimer("", 0.2f, "repeatmovebarrel1");
}
}

void repeatmovebarrel1(string &in asTimer, int alState)
{
GetLeverState("leverupdown");
{
if (alState == 1)
{
AddPropImpulse("barrel", 0, 0, 1.5, "world");
AddTimer("", 0.2f, "repeatmovebarrel1");
}

if (alState == -1)
{
AddPropImpulse("barrel", 0, 0, -1.5, "world");
AddTimer("", 0.2f, "repeatmovebarrel1");
}
}
}
I forgot to tell you that this script doesn't work, it acts like the second one mentioned above with only one propimpulse.
(This post was last modified: 01-16-2012, 11:23 PM by Yrasin.)
01-16-2012, 07:50 PM
Find
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#2
RE: Making a barrel controlled by levers

I once tried to make it so some levers I had placed played a sound effect each time they were in the up state, I did this in a very nooby way, I put script areas above the lever and made a collide callback for the lever and that area, this ended up with the sound repeating and repeating.

You could try making a script area where you want the lever to be when the barrel is moving and make it a collide callback between the lever and the script area. That could be a start anyway..

Current - Castle Darkuan
Other - F*cked Map
01-17-2012, 09:52 AM
Find




Users browsing this thread: 1 Guest(s)