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
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#12
RE: Let's play "why doesn't my script work?"!

Is the door far off at a distance, like in another room, from the valves? >= 4 should mean that the player only needs to have three valves turned correctly for the door to open, since you have not corrected the issue i pointed out.

Whether resetting the prop or setting the stuck state to unstuck, this does not reset the stuck state for the wheel.

Tutorials: From Noob to Pro
04-13-2013, 01:07 AM
Website Find
Streetboat Offline
Posting Freak

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

I've updated the code to include 5 valves (and I fixed the extra 1 input for each correct turn, which was making it activate earlier than it should have), and right now the only problem it has is the wheels not changing alState after an incorrect turn. It's actually breaking the puzzle as of now, because if you turn one wheel the wrong way, you have to turn it back the wrong way and then again back the right way in order to get it to tally +1 to "gateopen" again, and until then it'll always be however many wheels are turned the wrong way short of completing the puzzle.
void valve1turn(string &in asEntity, int alState)
{
if(alState == 1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 5)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        PlaySoundAtEntity("", "13_ignite.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "doorhum", 0, false);
        SetEntityActive("endwalk", true);
        }
    }
if(alState == -1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    StopSound("hum", 1);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=5;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=5;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    SetEntityActive("endwalk", false);
    }
}
void valve2turn(string &in asEntity, int alState)
{
if(alState == -1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 5)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        PlaySoundAtEntity("", "13_ignite.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "doorhum", 0, false);
        SetEntityActive("endwalk", true);
        }
    }
if(alState == 1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    StopSound("hum", 1);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=5;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=5;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    SetEntityActive("endwalk", false);
    }
}
void valve3turn(string &in asEntity, int alState)
{
if(alState == -1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 5)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        PlaySoundAtEntity("", "13_ignite.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "doorhum", 0, false);
        SetEntityActive("endwalk", true);
        }
    }
if(alState == 1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    StopSound("hum", 1);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=5;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=5;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    SetEntityActive("endwalk", false);
    }
}
void valve4turn(string &in asEntity, int alState)
{
if(alState == 1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 5)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        PlaySoundAtEntity("", "13_ignite.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "doorhum", 0, false);
        SetEntityActive("endwalk", true);
        }
    else
        {
        AddLocalVarInt("gateopen", 1);
        }
    }
if(alState == -1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    StopSound("hum", 1);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=5;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=5;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    SetEntityActive("endwalk", false);
    }
}
void valve5turn(string &in asEntity, int alState)
{
if(alState == -1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 5)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        PlaySoundAtEntity("", "13_ignite.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "doorhum", 0, false);
        SetEntityActive("endwalk", true);
        }
    }
if(alState == 1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    StopSound("hum", 1);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=5;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=5;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    SetEntityActive("endwalk", false);
    }
}
void valvereset(string &in asTimer)
{
    for(int i=1;i<=5;i++)ResetProp("valvepuzzle_"+i);
    for(int i=1;i<=5;i++)SetPropObjectStuckState("valvepuzzle_"+i, 0);
}
What code can I use that does reset the stuck state?

[Image: signature-2.png]
(This post was last modified: 04-13-2013, 01:44 AM by Streetboat.)
04-13-2013, 01:42 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#14
RE: Let's play "why doesn't my script work?"!

I don't think there's a way to reset the internal state for the valves, but gameplay wise i don't think that should be an issue. As far as the player is concerned, he just needs to turn a few valves, and a door opens. Why should they expect the door to close at any point after completing the puzzle? Why would the door require being closed for not getting the combination correct (since, presumably, the door is in a closed state by default)? Why should the valves be rotated to a 0 angle when rotated to the wrong state when the trial and error process is pretty much the same where valves do not try to reset their states when the puzzle is done incorrectly? Your code can be reduce to 1/4 to 1/3 or less of the current code and still get the same results.

Tutorials: From Noob to Pro
04-13-2013, 02:47 AM
Website Find
Streetboat Offline
Posting Freak

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

Back to the drawing board. I don't want it to be as simple as turning each valve left or right and just sticking with the direction that doesn't obviously fail. I know what to do, though. Thanks for helping! I think I got this. Smile

[Image: signature-2.png]
04-13-2013, 03:31 AM
Find
Streetboat Offline
Posting Freak

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

Got it. Smile

[Image: signature-2.png]
04-13-2013, 04:47 AM
Find




Users browsing this thread: 1 Guest(s)