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
Let's play "why doesn't my script work?"!
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#11
RE: Let's play "why doesn't my script work?"!

The door opens now properly, thanks! Smile

Now one final issue remains. When the correct input is made, it works fine, and then when you move it from the correct input to the incorrect one, the wheels do spin back to the middle, but they act as though they're still stuck on the alState they were previously at- i.e., they don't click when I move them back to their previous position and don't send any output. Essentially, they act as though they're still stuck on one side, and the only way to change that is to rotate it all the way to the other direction. I want it so that if the player gets it wrong, every single wheel acts as though it is in the middle again, so the player can try again from the beginning, rather than having to somehow know they need to rotate each wheel all the way back the other way, THEN back to the correct input. Here's my code.
void valve1turn(string &in asEntity, int alState)
{
if(alState == 1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 4)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        }
    else
        {
        AddLocalVarInt("gateopen", 1);
        }
    }
if(alState == -1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=4;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=4;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    }
}
void valve2turn(string &in asEntity, int alState)
{
if(alState == 1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 4)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        }
    else
        {
        AddLocalVarInt("gateopen", 1);
        }
    }
if(alState == -1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=4;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=4;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    }
}
void valve3turn(string &in asEntity, int alState)
{
if(alState == -1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 4)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        }
    else
        {
        AddLocalVarInt("gateopen", 1);
        }
    }
if(alState == 1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=4;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=4;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    }
}
void valve4turn(string &in asEntity, int alState)
{
if(alState == 1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 4)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        }
    else
        {
        AddLocalVarInt("gateopen", 1);
        }
    }
if(alState == -1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=4;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=4;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    }
}
void valvereset(string &in asTimer)
{
    for(int i=1;i<=4;i++)ResetProp("valvepuzzle_"+i);
}

[Image: signature-2.png]
(This post was last modified: 04-12-2013, 07:23 PM by Streetboat.)
04-12-2013, 07:21 PM
Find


Messages In This Thread
RE: Let's play "why doesn't my script work?"! - by Streetboat - 04-12-2013, 07:21 PM



Users browsing this thread: 1 Guest(s)