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
Variable not setting
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#1
Variable not setting

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: (Select All)
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);
        }
    }


(This post was last modified: 06-18-2012, 09:14 PM by Damascus.)
06-18-2012, 08:18 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#2
RE: Variable not setting

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.

06-18-2012, 08:24 PM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#3
RE: Variable not setting

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

06-18-2012, 09:13 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#4
RE: Variable not setting

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

06-18-2012, 10:37 PM
Find




Users browsing this thread: 1 Guest(s)