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
Script help.
Storfigge Offline
Member

Posts: 101
Threads: 31
Joined: Sep 2012
Reputation: 0
#1
Question  Script help.

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

04-16-2013, 07:10 PM
Find
Storfigge Offline
Member

Posts: 101
Threads: 31
Joined: Sep 2012
Reputation: 0
#2
RE: Script help.

Just noticed that I posted this in the wrong place -.- I tried to delete it but it doesn't work.

04-16-2013, 08:21 PM
Find
7heDubz Offline
Posting Freak

Posts: 1,329
Threads: 40
Joined: Feb 2013
Reputation: 41
#3
RE: Script help.

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.)

04-16-2013, 11:36 PM
Find
Traggey Offline
is mildly amused

Posts: 3,257
Threads: 74
Joined: Feb 2012
Reputation: 185
#4
RE: Script help.

Moved to development support.
04-17-2013, 01:03 AM
Find
7heDubz Offline
Posting Freak

Posts: 1,329
Threads: 40
Joined: Feb 2013
Reputation: 41
#5
RE: Script help.

Thaaanks Traggey!

04-17-2013, 01:15 AM
Find
Yare Offline
Junior Member

Posts: 22
Threads: 2
Joined: Mar 2013
Reputation: 0
#6
RE: Script help.

I think it will be like this, step by step:

SetLocalVarInt("BarrelCollisionCount", 0);

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

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.

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.
(This post was last modified: 04-17-2013, 01:55 AM by Yare.)
04-17-2013, 01:55 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#7
RE: Script help.

(04-17-2013, 01:55 AM)Yare Wrote: I think it will be like this, step by step:

SetLocalVarInt("BarrelCollisionCount", 0);

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

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.

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.

"Veni, vidi, vici."
"I came, I saw, I conquered."
04-17-2013, 06:15 AM
Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#8
RE: Script help.

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.

Creator of The Dark Treasure.
04-17-2013, 09:30 AM
Website Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#9
RE: Script help.

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.

Tutorials: From Noob to Pro
04-17-2013, 11:33 AM
Website Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#10
RE: Script help.

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.

Creator of The Dark Treasure.
04-17-2013, 02:38 PM
Website Find




Users browsing this thread: 1 Guest(s)