Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple Issues Help Creating A Lever Puzzle
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#11
RE: Creating A Lever Puzzle

I suppose you're talking about this part of your script:

PHP Code: (Select All)
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: (Select All)
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.


Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
12-12-2011, 10:17 PM
Find Reply
teddan50 Offline
Junior Member

Posts: 15
Threads: 2
Joined: Dec 2011
Reputation: 0
#12
RE: Creating A Lever Puzzle

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

PHP Code: (Select All)
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: (Select All)
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?
12-13-2011, 09:14 AM
Find Reply
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#13
RE: Creating A Lever Puzzle

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?


Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
12-13-2011, 04:17 PM
Find Reply
teddan50 Offline
Junior Member

Posts: 15
Threads: 2
Joined: Dec 2011
Reputation: 0
#14
RE: Creating A Lever Puzzle

(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...

(This post was last modified: 12-13-2011, 08:32 PM by teddan50.)
12-13-2011, 08:07 PM
Find Reply
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#15
RE: Creating A Lever Puzzle

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.

Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
12-13-2011, 08:09 PM
Find Reply
teddan50 Offline
Junior Member

Posts: 15
Threads: 2
Joined: Dec 2011
Reputation: 0
#16
RE: Creating A Lever Puzzle

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.
(This post was last modified: 12-13-2011, 09:09 PM by teddan50.)
12-13-2011, 09:03 PM
Find Reply
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#17
RE: Creating A Lever Puzzle

Replace that with this:

PHP Code: (Select All)
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.

Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
12-13-2011, 09:12 PM
Find Reply
teddan50 Offline
Junior Member

Posts: 15
Threads: 2
Joined: Dec 2011
Reputation: 0
#18
RE: Creating A Lever Puzzle

(12-13-2011, 09:12 PM)nemesis567 Wrote: Replace that with this:

PHP Code: (Select All)
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.
(This post was last modified: 12-13-2011, 09:45 PM by teddan50.)
12-13-2011, 09:25 PM
Find Reply
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#19
RE: Creating A Lever Puzzle

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.

Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
(This post was last modified: 12-13-2011, 09:32 PM by nemesis567.)
12-13-2011, 09:28 PM
Find Reply
teddan50 Offline
Junior Member

Posts: 15
Threads: 2
Joined: Dec 2011
Reputation: 0
#20
RE: Creating A Lever Puzzle

(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.
12-13-2011, 10:31 PM
Find Reply




Users browsing this thread: 1 Guest(s)