Frictional Games Forum (read-only)
Variable not setting - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Variable not setting (/thread-16280.html)



Variable not setting - Damascus - 06-18-2012

This stupid puzzle is still giving me a headache. I've set up a crank that raises a weight (as stated in an older thread), and when you wind it up, it is supposed to become stuck and set a variable. In the RaiseWeight function, everything works except for apparently the variable becoming one.

After I raise the weight, the light comes on and it becomes stuck, but when i go over to test the lever, it keeps playing the "notwound" message and does not become stuck.

PHP Code:
void OnStart()
{
    
SetEntityConnectionStateChangeCallback("lever_simple01_2""Lever2");
    
SetEntityConnectionStateChangeCallback("crank_iron_1""RaiseWeight");
}

void RaiseWeight(string &in asEntityint alState)
{
    if (
alState == 1)
    {
        
SetWheelStuckState("crank_iron_1"1true);
        
PlaySoundAtEntity("""fizzle""light_electric_1"0.0ffalse);
        
SetLampLit("light_electric_1"truetrue);
        
SetGlobalVarInt("WeightRaised"1);
    }
}

void Lever2(string &in asEntityint alState)
{
    if (
alState == 1)
    {
        if (
GetLocalVarInt("WeightRaised") == 1)
        {
            
SetLocalVarInt("PistonLevers"1);
            
PlaySoundAtEntity("""lever_mech_min_max""lever_simple01_2"0.0ffalse);
            
SetLeverStuckState("lever_simple01_2"1true);
            
AddTimer("WatchDisappear"RandFloat(10.0f30.0f), "WatchDisappear"); 
        }
        else
        {
            
SetMessage("Ch03Misc""notwound"0);
        }
    }




RE: Variable not setting - palistov - 06-18-2012

Add debug messages to make sure the lever is going to state 1. It could be going to state -1. Same with the wheel. Check its state with a debug message AddDebugMessage("state: "+alState, false);

I see no other way you could be getting this bug. Also, instead of setting the variable when the wheel reaches a certain state, do it when the weight object enters/exits a certain area. I've done that before and had everything turn out fine and dandy.


RE: Variable not setting - Damascus - 06-18-2012

Crap. I see what i did wrong now. I was setting a GLOBAL variable and checking a LOCAL variable. It's stupid mistakes like these that I only see after posting a thread about it. Tongue


RE: Variable not setting - palistov - 06-18-2012

Haha! It's the smallest of mistakes that get the best of us.