Frictional Games Forum (read-only)

Full Version: Lever help needed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
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. Huh (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);
}
Does anybody know an way Huh
It's pretty urgent I just want to have this part done.
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)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 Undecided
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.
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.
(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");
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
(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.
(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?
Pages: 1 2 3