Frictional Games Forum (read-only)

Full Version: Script help.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I wonder how to make like. Let's say I have three collide areas. When I place a barrel in one area nothing happens, but then if I place one barrel in each collide area a door open. So with to open the door I must place an object in three different areas. How to do this Tongue
Just noticed that I posted this in the wrong place -.- I tried to delete it but it doesn't work.
sounds like it would be a condition.. (If there is a barrel in these 3 area's then door will open) not sure how to do this though im a very basic scripter.

As for the second a mod will move it (I'll PM statyk and let him know.)
Moved to development support.
Thaaanks Traggey!
I think it will be like this, step by step:

Code:
SetLocalVarInt("BarrelCollisionCount", 0);

Just after "void OnStart/OnEnter" you declare a variable. It doesn't have to be "BarrelCollisionCount", name it as you wish.

Code:
AddEntityCollideCallback("BARREL NAME", "SCRIPTAREA1 NAME", "FUNCTION NAME", true, 1);
AddEntityCollideCallback("BARREL NAME", "SCRIPTAREA2 NAME", "FUNCTION NAME", true, 1);
AddEntityCollideCallback("BARREL NAME", "SCRIPTAREA3 NAME", "FUNCTION NAME", true, 1);

Here we add collide callback for 3 script areas. You can do it this way, though for more than 2 objects I usually use "for" loop.

Code:
void FUNCTION NAME(string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("BarrelCollisionCount", 1);
    if (GetLocalVarInt("BarrelCollisionCount")==3)
    {
        SetSwingDoorLocked("DOOR NAME", false, false);
        (And here put any other effects you would like to play. Maybe unlock sound, or something like that)
    }
}

Every time the function is played, it adds 1 to the variable and checks if the variable equals 3. On the 3rd collision it should unlock the door.
(04-17-2013, 01:55 AM)Yare Wrote: [ -> ]I think it will be like this, step by step:

Code:
SetLocalVarInt("BarrelCollisionCount", 0);

Just after "void OnStart/OnEnter" you declare a variable. It doesn't have to be "BarrelCollisionCount", name it as you wish.

Code:
AddEntityCollideCallback("BARREL NAME", "SCRIPTAREA1 NAME", "FUNCTION NAME", true, 1);
AddEntityCollideCallback("BARREL NAME", "SCRIPTAREA2 NAME", "FUNCTION NAME", true, 1);
AddEntityCollideCallback("BARREL NAME", "SCRIPTAREA3 NAME", "FUNCTION NAME", true, 1);

Here we add collide callback for 3 script areas. You can do it this way, though for more than 2 objects I usually use "for" loop.

Code:
void FUNCTION NAME(string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("BarrelCollisionCount", 1);
    if (GetLocalVarInt("BarrelCollisionCount")==3)
    {
        SetSwingDoorLocked("DOOR NAME", false, false);
        (And here put any other effects you would like to play. Maybe unlock sound, or something like that)
    }
}

Every time the function is played, it adds 1 to the variable and checks if the variable equals 3. On the 3rd collision it should unlock the door.
You put the SetLocalVarInt to the void OnStart() part. And if the Player must do all this to unlock a door, and if it locks again if no barrels are in place then you'll need another script.
Keep in mind that unless you make the barrels unmovable after it has been placed, the player can freely remove the barrels and still have the possibility to unlock the door. To avoid this, I would make three separate variables. For each of the areas the barrels are supposed to stand in, I would make sure that the alState of the collide area can be triggered both when inside, and outside of the box. When the barrel is inside the box, the variable would be set to 1 and when outside, it would be set back to 0.
That way, the barrels must be inside the areas in order to unlock the door.
The script provided satisfies what Storfigge wanted, since only one barrel is going to be used for the three areas anyway, not three barrels for three areas.
Quote: but then if I place one barrel in each collide area a door open
I went from that, which he implies that it is one for each collide, hence three barrels.
Pages: 1 2