Steve
Member
Posts: 178
Threads: 17
Joined: Jun 2012
Reputation:
7
|
Lever help needed
Well I think I know a way for how to do what I want to do. but I still need help look I have an lever I want it to open a hatch when you pull it like up and when you pull it down I want it to close again, but My code doesn't seem to work. (I know my code is actually only for opening it)this is my code I hope you guys could help.
void OnStart()
{
InteractConnectPropWithMoveObject("wheeltodoor1", "wheelrust", "GateOpenClose", true, false, 0);
InteractConnectPropWithMoveObject("wheeltodoor1", "wheelrusttwo", "GateOpenClose", true, false, 0);
AddEntityCollideCallback("Player", "Gategoeslocked", "CloseGate", true, 1);
SetEntityPlayerInteractCallback("wheelrustthree", "rustwheel", false);
AddEntityCollideCallback("Lever", "Mount" , "LeverMount", true, 1);
SetEntityConnectionStateChangeCallback("LeverComplete", "leverfunc");
}
void CloseGate(string &in asParent, string &in asChild, int asEntity)
{
SetMoveObjectStateExt("GateOpenClose", 0, 8, 16, 0, false);
CreateParticleSystemAtEntity("", "ps_dust_elevator_crash.ps", "Dust_6", false);
SetEntityActive("wheelrusttwo", false);
SetEntityActive("wheelrustthree", true);
SetWheelInteractionDisablesStuck("wheelrusttwo", false);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
GiveSanityDamage(10, true);
}
void rustwheel(string &in entity)
{
SetMessage("Messages", "DoorClosed", 0);
}
void LeverMount(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Lever" , false);
SetEntityActive("LeverComplete" , true);
SetEntityActive("Mount", false);
}
void leverfunc(string &in asEntity, int alState)
{
if (alState == 1)
SetSwingDoorLocked("hatch_drainage_1", false, true);
PlaySoundAtEntity("", "unlock_door", "hatch_drainage_1", 0, false);
}
(This post was last modified: 07-04-2012, 09:37 PM by Traggey.)
|
|
07-03-2012, 08:57 PM |
|
Steve
Member
Posts: 178
Threads: 17
Joined: Jun 2012
Reputation:
7
|
RE: Lever help needed
Does anybody know an way
It's pretty urgent I just want to have this part done.
(This post was last modified: 07-04-2012, 01:46 PM by Steve.)
|
|
07-04-2012, 01:11 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: Lever help needed [UNSOLVED]
Why haven't you thought about checking if alState is equal to -1, and if so, close and lock the door? If you're looking for the door to open without the player interacting with the hatch, you're going to need to apply force or an impulse to the entity after unlocking, disabling autoclose and opening.
Study: http://wiki.frictionalgames.com/hpl2/amn..._functions
|
|
07-04-2012, 01:46 PM |
|
Steve
Member
Posts: 178
Threads: 17
Joined: Jun 2012
Reputation:
7
|
RE: Lever help needed [UNSOLVED]
(07-04-2012, 01:46 PM)Your Computer Wrote: Why haven't you thought about checking if alState is equal to -1, and if so, close and lock the door? If you're looking for the door to open without the player interacting with the hatch, you're going to need to apply force or an impulse to the entity after unlocking, disabling autoclose and opening.
Study: http://wiki.frictionalgames.com/hpl2/amn..._functions
Yeah Thanks for the advice.
But to be honest I have no idea what you mean with all that
I only starded for about a week and a half now.
And I have the hatch like this if it would help anything.
http://i47.tinypic.com/fmje5e.png
I have been studying the engine scripts, And I have been looking at old threads but I just can't seem to figure it out. If you could give an example code of what you mean with what you say it could help me alot.and by the way i have a rope attached to the hatch I don't think that would change any of the code but still I thought it would be better if I would include it .
The thing i want is like when you pull a lever the hatch goes open.
(This post was last modified: 07-04-2012, 02:03 PM by Steve.)
|
|
07-04-2012, 02:01 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: Lever help needed [UNSOLVED]
|
|
07-04-2012, 03:10 PM |
|
EddieShoe
Junior Member
Posts: 28
Threads: 6
Joined: Sep 2010
Reputation:
0
|
RE: Lever help needed [UNSOLVED]
So, I think I got what you meant. It works for me on my map, but I am not 100% sure this is what you wanted. I'm no pro at this either, I just tried my best. I've learned a lot from Your Computer so you should definitely try out his tutorials. Anyway, here's the script:
void leverfunc(string &in asEntity, int alState)
{
if (alState == 1)
{
SetSwingDoorClosed("your_door_here", false, false); Don't know if this has to be here, opens to door.
SetSwingDoorDisableAutoClose("your_door_here ", true); Disables auto-closing of the door.
AddPropImpulse("your_door_here ", X, Y, >, "world"); Opens the door in the desired direction.
return;
}
if (alState == -1)
SetSwingDoorClosed("your_door_here", true, false); Closes the door.
}
EDIT: Maybe you want to add SetSwingDoorDisableAutoClose("your_door_here ", false); under the -1 state as well, just before the SetSwingDoorClosed.
Currently working on: "Awake"
Progress: ~5%
(This post was last modified: 07-04-2012, 03:56 PM by EddieShoe.)
|
|
07-04-2012, 03:55 PM |
|
Steve
Member
Posts: 178
Threads: 17
Joined: Jun 2012
Reputation:
7
|
RE: Lever help needed [UNSOLVED]
(07-04-2012, 03:55 PM)EddieShoe Wrote: So, I think I got what you meant. It works for me on my map, but I am not 100% sure this is what you wanted. I'm no pro at this either, I just tried my best. I've learned a lot from Your Computer so you should definitely try out his tutorials. Anyway, here's the script:
void leverfunc(string &in asEntity, int alState)
{
if (alState == 1)
{
SetSwingDoorClosed("your_door_here", false, false); Don't know if this has to be here, opens to door.
SetSwingDoorDisableAutoClose("your_door_here ", true); Disables auto-closing of the door.
AddPropImpulse("your_door_here ", X, Y, >, "world"); Opens the door in the desired direction.
return;
}
if (alState == -1)
SetSwingDoorClosed("your_door_here", true, false); Closes the door.
}
EDIT: Maybe you want to add SetSwingDoorDisableAutoClose("your_door_here ", false); under the -1 state as well, just before the SetSwingDoorClosed. It gives me this error :/
main (41, 43): ERR : Exected expresion value
I put it in like this.
void OnStart()
{
SetEntityConnectionStateChangeCallback("LeverComplete", "leverfunc");
}
void leverfunc(string &in asEntity, int alState)
{
if (alState == 1)
{
SetSwingDoorClosed("hatch_drainage_1", false, false);
SetSwingDoorDisableAutoClose("hatch_drainage_1", true);
AddPropImpulse("hatch_drainage_1", 0, 0, >, "world");
return;
}
if (alState == -1)
SetSwingDoorClosed("hatch_drainage_1", true, false);
SetSwingDoorDisableAutoClose("hatch_drainage_1", true);
}
at the X and Y part I had no idea what to fill in so I just put 0, 0 like YC
line 41 is : AddPropImpulse("hatch_drainage_1", 0, 0, >, "world");
|
|
07-04-2012, 04:22 PM |
|
Cruzore
Senior Member
Posts: 301
Threads: 2
Joined: Jun 2012
Reputation:
37
|
RE: Lever help needed [UNSOLVED]
at the propimpulse line is >
that should be replaced with a number. since you want it to go up I assume, put a positive number at Y like 800, and the rest goes 0
Think, before you speak Google, before you post
(This post was last modified: 07-04-2012, 04:24 PM by Cruzore.)
|
|
07-04-2012, 04:23 PM |
|
EddieShoe
Junior Member
Posts: 28
Threads: 6
Joined: Sep 2010
Reputation:
0
|
RE: Lever help needed [UNSOLVED]
(07-04-2012, 04:22 PM)Steve Wrote: (07-04-2012, 03:55 PM)EddieShoe Wrote: So, I think I got what you meant. It works for me on my map, but I am not 100% sure this is what you wanted. I'm no pro at this either, I just tried my best. I've learned a lot from Your Computer so you should definitely try out his tutorials. Anyway, here's the script:
void leverfunc(string &in asEntity, int alState)
{
if (alState == 1)
{
SetSwingDoorClosed("your_door_here", false, false); Don't know if this has to be here, opens to door.
SetSwingDoorDisableAutoClose("your_door_here ", true); Disables auto-closing of the door.
AddPropImpulse("your_door_here ", X, Y, >, "world"); Opens the door in the desired direction.
return;
}
if (alState == -1)
SetSwingDoorClosed("your_door_here", true, false); Closes the door.
}
EDIT: Maybe you want to add SetSwingDoorDisableAutoClose("your_door_here ", false); under the -1 state as well, just before the SetSwingDoorClosed. It gives me this error :/
main (41, 43): ERR : Exected expresion value
I put it in like this.
void OnStart()
{
SetEntityConnectionStateChangeCallback("LeverComplete", "leverfunc");
}
void leverfunc(string &in asEntity, int alState)
{
if (alState == 1)
{
SetSwingDoorClosed("hatch_drainage_1", false, false);
SetSwingDoorDisableAutoClose("hatch_drainage_1", true);
AddPropImpulse("hatch_drainage_1", 0, 0, >, "world");
return;
}
if (alState == -1)
SetSwingDoorClosed("hatch_drainage_1", true, false);
SetSwingDoorDisableAutoClose("hatch_drainage_1", true);
}
at the X and Y part I had no idea what to fill in so I just put 0, 0 like YC
line 41 is : AddPropImpulse("hatch_drainage_1", 0, 0, >, "world");
AH! I forgot to change that typo, it's supposed to say X, Y, Z and you have to change it to the axis you want it to move along. That was a minor mistake but still dumb, sorry! Example is 0, 0, 15, that will move it +15 along the Z axis.
Currently working on: "Awake"
Progress: ~5%
|
|
07-04-2012, 04:37 PM |
|
Steve
Member
Posts: 178
Threads: 17
Joined: Jun 2012
Reputation:
7
|
RE: Lever help needed [UNSOLVED]
(07-04-2012, 04:23 PM)FastHunteR Wrote: at the propimpulse line is >
that should be replaced with a number. since you want it to go up I assume, put a positive number at Y like 800, and the rest goes 0 I can't realy see if it works xD I have an lever small so every time I pull it down it goes to the middel again do you know how to keep it so that it stays down?
|
|
07-04-2012, 04:56 PM |
|
|