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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lever puzzle
Endrek03 Offline
Junior Member

Posts: 8
Threads: 3
Joined: Dec 2010
Reputation: 0
#1
Lever puzzle

Hey all,

New to the forums, new to HPL, and new to scripting language (C++?).
. . . I know, so grating on your ears, right? Tongue

I'm great at picking things up and have been teaching myself as I go. I'm actually quite surprised at how far I've come without having to come on the forums.
But, alas, something has kicked my butt.

In my game, the player goes into the attic and is greeted by 5 levers and a locked chest. Using other information obtained, they must pull the levers in a certain order to unlock the chest. The order is 3 - 5 - 1 - 3. 4 is not touched.
For the life of me I can't figure out how to make this happen.

I was able to find a Thread in which the player had to light candles in a certain order, but unfortunately the code base is too different to transfer over simply enough, or at least I'm too out of it to figure it out.

This is what I was able to change it to:

Spoiler below!

void combolever(string &in asEntity, string &in asType)
{
if(asType == "OnPull")
{

if((asEntity == "lever_combo_3") && (GetLocalVarInt("combototal") == 0))
{
AddLocalVarInt("comboright", 1);
}
if((asEntity == "lever_combo_5") && (GetLocalVarInt("combototal") == 1))
{
AddLocalVarInt("comboright", 1);
}
if((asEntity == "lever_combo_1") && (GetLocalVarInt("combototal") == 2))
{
AddLocalVarInt("comboright", 1);
}
if((asEntity == "lever_combo_3") && (GetLocalVarInt("combototal") == 3))
{
AddLocalVarInt("comboright", 1);
}

AddLocalVarInt("combototal", 1);

if((GetLocalVarInt("combototal") == 4))
{
if(GetLocalVarInt("combototal") == GetLocalVarInt("comboright"))
{
PlaySoundAtEntity("rawr", "guardian_ontop.snt", "Player", 0.0f, false);
SetLeverStuckState("chest_kitchen_1", 1, false);
}
else if(GetLocalVarInt("comboright") < GetLocalVarInt("combototal"))
{
SetLocalVarInt("comboright", 0);
SetLocalVarInt("combototal", 0);

}
}
}
}


Something in there doesn't feel like working.
Any help? And more importantly the why? I'm a big fan of teaching a man how to fish. Smile
12-14-2010, 06:41 AM
Find
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#2
RE: Lever puzzle

AddDebugMessage is your friend here. Use it to check if the combototal count works and if it does, check the comboright variable. It's quite an advanced thing to script, there aren't many here that could do this, myself included Big Grin


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
12-14-2010, 05:46 PM
Find
Endrek03 Offline
Junior Member

Posts: 8
Threads: 3
Joined: Dec 2010
Reputation: 0
#3
RE: Lever puzzle

(12-14-2010, 05:46 PM)Frontcannon Wrote: AddDebugMessage is your friend here. Use it to check if the combototal count works and if it does, check the comboright variable. It's quite an advanced thing to script, there aren't many here that could do this, myself included Big Grin

Don't mean to be the complete new guy, but -- How exactly does the AddDebugMessage work?
I tried sticking it in OnStart as:
AddDebugMessage("combolever", true);
which I assumed would make the debug message come up for the syntax "Combolever", but no such luck.
12-14-2010, 10:12 PM
Find
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#4
RE: Lever puzzle

http://wiki.frictionalgames.com/hpl2/amn..._functions is your friend Smile
12-14-2010, 10:24 PM
Find
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#5
RE: Lever puzzle

Always set the boolean to false, I've never used it any other way.
Also make sure you have 'Display Debug Messages' (or the like) checked in your debug menu!

OH.
You're using it completely wrong so far D:
Let's have a look in my scripts somewhere.. here you go:
void SkullRoomLookAt(string &in entity, int alState)
{
    if(alState == -1)
    {
        SetEntityActive("CollideSkullRoom", true);
        AddDebugMessage("keep not looking..", false);
    }
    else
    {
        SetEntityActive("CollideSkullRoom", false);
        AddDebugMessage("don't look!", false);
    }
}

AddDebugMessage triggers when the normal function is called and then displays a little message (the string) in the bottom left of the screen. You use it to check if a CollideArea works (little message pops up -> yes, works, the error has to be in somewhere else! OR no message -> hm, area doesn't trigger) or a little more complicated in my case if you're looking at something (else) or not (the if case).


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
(This post was last modified: 12-14-2010, 10:39 PM by Frontcannon.)
12-14-2010, 10:34 PM
Find




Users browsing this thread: 1 Guest(s)