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
Lamp puzzle scripting help
Alexander Offline
Junior Member

Posts: 22
Threads: 2
Joined: Sep 2010
Reputation: 0
#8
RE: Lamp puzzle scripting help

You can also add some debug messages to the code to help give a better visual of how the script is working when running in debug mode.

void combolit(string &in asEntity, string &in asType)
{
    if(asType == "OnIgnite")
    {
    
        // Here I named the candles in ascending order, 1 being what I want lit first, 4 last.  Using a local variable, I keep
        // track of how far along I am in the sequence.  If the right one is lit at the right time, it adds one to how many
        // were gotten right, if not, it does nothing.
        if((asEntity == "candle_combo_1") && (GetLocalVarInt("combototal") == 0))
        {
            AddLocalVarInt("comboright", 1);

        }
        if((asEntity == "candle_combo_2") && (GetLocalVarInt("combototal") == 1))
        {
            AddLocalVarInt("comboright", 1);

        }
        if((asEntity == "candle_combo_3") && (GetLocalVarInt("combototal") == 2))
        {
            AddLocalVarInt("comboright", 1);

        }
        if((asEntity == "candle_combo_4") && (GetLocalVarInt("combototal") == 3))
        {
            AddLocalVarInt("comboright", 1);

        }
        
        // I add one to the total lit regardless
        AddLocalVarInt("combototal", 1);
        AddDebugMessage("combototal: "+GetLocalVarInt("combototal"), false);
        AddDebugMessage("comboright: "+GetLocalVarInt("comboright"), false);
        
        // If we have all 4 lit...
        if((GetLocalVarInt("combototal") == 4))
        {
            // Were all the ones lit in correct order?
            if(GetLocalVarInt("combototal") == GetLocalVarInt("comboright"))
            {
                PlaySoundAtEntity("rawr", "guardian_ontop.snt", "Player", 0.0f, false);
                AddDebugMessage("combototal and comboright are equal: SUCCESS!!!", false);
            }
            // Or did we get off track somewhere.
            else if(GetLocalVarInt("comboright") < GetLocalVarInt("combototal"))
            {
                // If we got something wrong, reset the checking values
                SetLocalVarInt("comboright", 0);
                SetLocalVarInt("combototal", 0);
                AddDebugMessage("comboright is less than combototal", false);
                
                // And kill the candles (timer due to trouble otherwise)
                // so player can try again.
                AddTimer("killcandles", 0.25f, "killcandles");
            }
        }
    }
}

void killcandles(string &in asTimer)
{
for(int i = 1; i <= 4 ; i++)
    {
        SetLampLit("candle_combo_" + i, false, false);
        AddDebugMessage("Turning lights off: candle_combo_"+i, false); //comment this out if you don't want massive spam xD -- or just delete it :D
    }
}
Since I have no scripting experience, I tend find debug messages a great way to learn the code alot faster. Big Grin

Thanks for writing up the script, Entih. I'll be sure to save it back... Never know when good stuff like this will come in handy. And also, as Soon said, it's good to stare at it and study it for awhile. Smile

*Edit - Forgot to add something. :/
10-04-2010, 09:35 AM
Find


Messages In This Thread
Lamp puzzle scripting help - by Soon - 10-03-2010, 07:18 PM
RE: Lamp puzzle scripting help - by Entih - 10-03-2010, 07:40 PM
RE: Lamp puzzle scripting help - by Soon - 10-03-2010, 10:35 PM
RE: Lamp puzzle scripting help - by Entih - 10-03-2010, 11:08 PM
RE: Lamp puzzle scripting help - by Soon - 10-04-2010, 12:58 AM
RE: Lamp puzzle scripting help - by Entih - 10-04-2010, 02:01 AM
RE: Lamp puzzle scripting help - by Soon - 10-04-2010, 03:13 AM
RE: Lamp puzzle scripting help - by Alexander - 10-04-2010, 09:35 AM



Users browsing this thread: 1 Guest(s)