The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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
#1
Let's play "why doesn't my script work?"!

Okay, so here's the scenario. Four valves (each starting at the middle position) turn in a specific order to open a portcullis. The correct order goes as such: R R L R. If the player gets one wrong, steam spurts out of a pipe and the order resets. Seems simple enough, right? Right. Here's the 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 == 0)
    {
    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);
    }
}
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 == 0)
    {
    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);
    }
}
void valve3turn(string &in asEntity, int alState)
{
if(alState == 0)
    {
    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);
    }
}
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 == 0)
    {
    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);
    }
}

Here's where it sucks. If I input the correct order, nothing happens. The portcullis is still stuck there. If I move any of the wheels other than the third to any position, nothing happens. Left or right, wheels 1, 2, and 4 do nothing. Wheel 3 acts as it should; right (the wrong direction) does the steam thing and resets the wheels, and left clicks as it should.

So, what do? Why won't this work? I feel like my logic is fairly sound withing the coding. It's late, and I don't want to work on this any more, so I was hoping someone more experienced had some insight. Smile

[Image: signature-2.png]
(This post was last modified: 04-13-2013, 04:47 AM by Streetboat.)
04-12-2013, 06:05 AM
Find


Messages In This Thread
Let's play "why doesn't my script work?"! - by Streetboat - 04-12-2013, 06:05 AM



Users browsing this thread: 1 Guest(s)