[SCRIPT] Making a barrel controlled by levers - 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] Making a barrel controlled by levers (/thread-12641.html) |
Making a barrel controlled by levers - Yrasin - 01-16-2012 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. RE: Making a barrel controlled by levers - Shadowfied - 01-17-2012 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.. |