The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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


Messages In This Thread
Making a barrel controlled by levers - by Yrasin - 01-16-2012, 07:50 PM



Users browsing this thread: 1 Guest(s)