Frictional Games Forum (read-only)

Full Version: Creating A Lever Puzzle
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I suppose you're talking about this part of your script:

PHP Code:
void PerformLeverTaskCompleted()
 {
 
SetSwingDoorLocked("door1"falsefalse);
 
SetSwingDoorClosed("door1"falsefalse);
 
PlaySoundAtEntity("""unlock_door""door1"0false);
 
PlaySoundAtEntity("""quest_completed.snt""Player"0.5ffalse);
 
StartEffectFlash(10.41);
 } 

Note that to lock the door these functions should be:

PHP Code:
SetSwingDoorLocked("door1"truefalse);
 
SetSwingDoorClosed("door1"truefalse); 

What kind of door are you trying to open. Is it a swing type door? Like the ones you can interact to move open?

___________

About the sound and light. That probably happens because function PerformLeverTaskCompleted is not being called. Please activate debug mode and find out if that's the reason.

(12-12-2011, 10:17 PM)nemesis567 Wrote: [ -> ]I suppose you're talking about this part of your script:

PHP Code:
void PerformLeverTaskCompleted() 

SetSwingDoorLocked("door1"falsefalse); 
SetSwingDoorClosed("door1"falsefalse); 
PlaySoundAtEntity("""unlock_door""door1"0false); 
PlaySoundAtEntity("""quest_completed.snt""Player"0.5ffalse); 
StartEffectFlash(10.41); 



Note that to lock the door these functions should be:

PHP Code:
SetSwingDoorLocked("door1"truefalse); 
SetSwingDoorClosed("door1"truefalse); 


What kind of door are you trying to open. Is it a swing type door? Like the ones you can interact to move open?

___________

About the sound and light. That probably happens because function PerformLeverTaskCompleted is not being called. Please activate debug mode and find out if that's the reason.


Yes, it is a swing door. I got it to lock now, but when I pull the levers it doesn't unlock....

How do I activate debug mode?
Set up a development environment like described in here:

http://wiki.frictionalgames.com/hpl2/amn...evenvguide

Note: Make sure that you are using the following code for the PerformLeverTaskCompleted function.

void PerformLeverTaskCompleted()
{
SetSwingDoorLocked("door1", false, false);
SetSwingDoorClosed("door1", false, false);
PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
PlaySoundAtEntity("", "quest_completed.snt", "Player", 0.5f, false);
StartEffectFlash(1, 0.4, 1);
}


What have you done to get it to lock?

(12-13-2011, 04:17 PM)nemesis567 Wrote: [ -> ]Set up a development environment like described in here:

http://wiki.frictionalgames.com/hpl2/amn...evenvguide

Note: Make sure that you are using the following code for the PerformLeverTaskCompleted function.

void PerformLeverTaskCompleted()
{
SetSwingDoorLocked("door1", false, false);
SetSwingDoorClosed("door1", false, false);
PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
PlaySoundAtEntity("", "quest_completed.snt", "Player", 0.5f, false);
StartEffectFlash(1, 0.4, 1);
}


What have you done to get it to lock?


I have now tried the debug mode, no difference...

I don't really know how I made it work... I tried desperately tried different combinations of the "true" and "false". When I setted it as shown it worked Tongue: SetSwingDoorLocked("door1", true, false);

But as said, the door just won't unlock!!!

Edit:
I realized that my door wasn't propertly placed in the doorway Tongue

I now tried to take the 4 levers that shouldn't be pulled out of the script so it looks like this:

void OnStart()
{
SetEntityConnectionStateChangeCallback("lever_1", "StoreCheckLeverState");
SetEntityConnectionStateChangeCallback("lever_3", "StoreCheckLeverState");
SetEntityConnectionStateChangeCallback("lever_5", "StoreCheckLeverState");
SetEntityConnectionStateChangeCallback("lever_8", "StoreCheckLeverState");
}


void CheckLeverStates()
{
if (GetLocalVarInt("lever_1") == 0
&& GetLocalVarInt("lever_3") == 0
&& GetLocalVarInt("lever_5") == 0
&& GetLocalVarInt("lever_8") == 0)
{
PerformLeverTaskCompleted();
}
}
void PerformLeverTaskCompleted()
{
SetSwingDoorLocked("door1", true, false);
PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
PlaySoundAtEntity("", "quest_completed.snt", "Player", 0.5f, false);
StartEffectFlash(1, 0.4, 1);
}

void StoreCheckLeverState(string &in entity, int state)
{
SetLocalVarInt(entity, state);
CheckLeverStates();
}

But now when I pull the first lever, the music and flash starts, but the door doesn't unlock?! I have scripted it so if all 4 levers are pulled the PerformLeverTaskCompleted starts (right?) and if it does, the door should unlock itself.

I just can't understand what I'm doing wrong...

Follow the procedure:Find:

SetSwingDoorLocked
("door1", true, false);

replace with:SetSwingDoorLocked("door1", false, false);

What you were doing was locking the already locked door if I'm right.
Ok, now the door opens. But I want it to open when all 4 levers all pulled...

It must be this part of the script that is wrong:

void CheckLeverStates()
{
if (GetLocalVarInt("lever_1") == 0
&& GetLocalVarInt("lever_3") == 0
&& GetLocalVarInt("lever_5") == 0
&& GetLocalVarInt("lever_8") == 0)
{
PerformLeverTaskCompleted();
}
}

... but I can't see what is wrong.
Replace that with this:

PHP Code:
void CheckLeverStates()
 {
     if (
GetLocalVarInt("lever_1") == 1
      
&& GetLocalVarInt("lever_3") == 1
      
&& GetLocalVarInt("lever_5") == 1
      
&& GetLocalVarInt("lever_8") == 1)
     {
          
PerformLeverTaskCompleted();
     }
 } 

That happens because you want stuff to happen when they are all pulled and not in neutral state.
(12-13-2011, 09:12 PM)nemesis567 Wrote: [ -> ]Replace that with this:

PHP Code:
void CheckLeverStates() 

if (
GetLocalVarInt("lever_1") == 
&& GetLocalVarInt("lever_3") == 
&& GetLocalVarInt("lever_5") == 
&& GetLocalVarInt("lever_8") == 1

PerformLeverTaskCompleted(); 




That happens because you want stuff to happen when they are all pulled and not in neutral state.


The reason that I did it that way was because I setted all of the levers on Max, I figured that if all of the 4 levers was in 0 on the same time it just had to work. But I tried to set all of the levers so they where in the middle and did as you said, but it didn't work...

The final function didn't start at all that is.
The code I last posted should call PerformLeverTaskCompleted when both lever 1, 3, 5 and 8 are turned up(or down depending on the orientation). I don't exactly get what you meant in your last post. Maybe you could try to explain better.

Please give a detailed explanation on how does the door open and when.
(12-13-2011, 09:28 PM)nemesis567 Wrote: [ -> ]The code I last posted should call PerformLeverTaskCompleted when both lever 1, 3, 5 and 8 are turned up(or down depending on the orientation). I don't exactly get what you meant in your last post. Maybe you could try to explain better.

Please give a detailed explanation on how does the door open and when.


Ok,

I pull the 4 levers (they slide back into their former position if that's the problem), but now the PerformLeverTaskCompleted doesn't start at all. That means, no music/lights/door unlocking.
Pages: 1 2 3