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)Lever Opens a Door
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#1
(Script)Lever Opens a Door

Hi, guys. I'm making a custom story and there's a lever that opens and closes a door. The name of the door is "wooden_slide_door_1". And I have no idea how to script it. Can someone tell me how to do it ?

[Image: the-cabin-in-the-woods-masked-people.jpg]
06-12-2012, 08:46 AM
Find
Putkimato Offline
Junior Member

Posts: 25
Threads: 8
Joined: Jun 2012
Reputation: 0
#2
RE: (Script)Lever Opens a Door

void OnStart()

{

SetEntityConnectionStateChangeCallback("lever", "leverfunc");
SetEntityConnectionStateChangeCallback("lever", "leverfunc2");
}

void leverfunc(string &in asEntity, int alState)
{
if (alState == 1)

SetSwingDoorLocked("door", false, true);
PlaySoundAtEntity("", "unlock_door", "door", 0, false);
}

void leverfunc2(string &in asEntity, int alState)
{
if (alState == -1)

SetSwingDoorClosed("door", false, true);
PlaySoundAtEntity("", "unlock_door", "door", 0, false);
}

When you drag lever down, door unlocks, and when you stop dragging it down, it locks.. Its kinda buggy script, i can make it better if you need Smile
(This post was last modified: 06-12-2012, 12:34 PM by Putkimato.)
06-12-2012, 12:12 PM
Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#3
RE: (Script)Lever Opens a Door

Make it better please

And BTW does that work for valves ?

[Image: the-cabin-in-the-woods-masked-people.jpg]
(This post was last modified: 06-12-2012, 01:03 PM by No Author.)
06-12-2012, 12:54 PM
Find
Putkimato Offline
Junior Member

Posts: 25
Threads: 8
Joined: Jun 2012
Reputation: 0
#4
RE: (Script)Lever Opens a Door

(06-12-2012, 12:54 PM)TheNoAuthor12 Wrote: Make it better please

And BTW does that work for valves ?
Maybe, what if you make two levers? another opens, another closes
06-12-2012, 03:23 PM
Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#5
RE: (Script)Lever Opens a Door

Okay. But, I want to make lever that opens and closes the door. Is that possible ?

[Image: the-cabin-in-the-woods-masked-people.jpg]
06-13-2012, 06:40 AM
Find
Putkimato Offline
Junior Member

Posts: 25
Threads: 8
Joined: Jun 2012
Reputation: 0
#6
RE: (Script)Lever Opens a Door

(06-13-2012, 06:40 AM)TheNoAuthor12 Wrote: Okay. But, I want to make lever that opens and closes the door. Is that possible ?
I think it is.. But its hard, i always just make 2 levers Tongue Im not good scripter, started like month ago.
06-13-2012, 09:48 AM
Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#7
RE: (Script)Lever Opens a Door

(06-13-2012, 09:48 AM)Putkimato Wrote:
(06-13-2012, 06:40 AM)TheNoAuthor12 Wrote: Okay. But, I want to make lever that opens and closes the door. Is that possible ?
I think it is.. But its hard, i always just make 2 levers Tongue Im not good scripter, started like month ago.
I started like a few days ago.

[Image: the-cabin-in-the-woods-masked-people.jpg]
06-13-2012, 09:57 AM
Find
SilentHideButFine Offline
Member

Posts: 156
Threads: 38
Joined: May 2012
Reputation: 6
#8
RE: (Script)Lever Opens a Door

(06-12-2012, 08:46 AM)TheNoAuthor12 Wrote: Hi, guys. I'm making a custom story and there's a lever that opens and closes a door. The name of the door is "wooden_slide_door_1". And I have no idea how to script it. Can someone tell me how to do it ?
Take the script he gave you its good and easy to understand if not follow this (this tut is with buttons)

http://wiki.frictionalgames.com/hpl2/tut...pen_a_door

Smile


oid OnStart()
{
SetLocalVarInt("Var1", 0);
SetEntityPlayerInteractCallback("button1", "func1", true);
SetEntityPlayerInteractCallback("button2", "func2", true);
SetEntityPlayerInteractCallback("button3", "func3", true);
SetEntityPlayerInteractCallback("button4", "func4", true);
}

void func1(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func2(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func3(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func4(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func5()
{
if(GetLocalVarInt("Var1") == 4)
{
/////add what ever you want to happen after you press all 4 buttons here.
SetSwingDoorLocked("door1", false, false);
PlaySoundAtEntity("", "unlock_door.snt", "door1", 0.5f, false);
}
}
I think you can change the Entity to lever not sure but anywaySmile

[url= http://www.moddb.com/mods/jessehmusic [/url] ,HOSPITAL OF HORROR MOD
06-13-2012, 10:21 AM
Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#9
RE: (Script)Lever Opens a Door

I'll try it first then change it to a lever

It doesn't work. I can't get it open.

[Image: the-cabin-in-the-woods-masked-people.jpg]
(This post was last modified: 06-13-2012, 10:56 AM by No Author.)
06-13-2012, 10:27 AM
Find
Theforgot3n1 Offline
Member

Posts: 192
Threads: 20
Joined: Apr 2012
Reputation: 6
#10
RE: (Script)Lever Opens a Door

Ehm, so you want a button that closes and locks the door at the same time when pushed?

void OnStart()



{



SetEntityConnectionStateChangeCallback("lever", "leverfunc");

SetEntityConnectionStateChangeCallback("lever", "leverfunc2");

}



void leverfunc(string &in asEntity, int alState)

{

if (alState == 1)
SetMoveObjectStateExt("wooden_slide_door_1", 1.0f, 1.0f, 5.0f, 5.0f, true);
//All the numbers on the script above depends on what speed you want it to open. Check out "Engine Scripts" //in the wiki for more information.

}



void leverfunc2(string &in asEntity, int alState)

{

if (alState == -1)

SetMoveObjectStateExt("wooden_slide_door_1", 0.0f, 1.0f, 5.0f, 5.0f, true);

}

That should be all. I'm slightly unsure if the SetMoveObjectStateExt works exactly like they should. But yeah, you can always check the Engine Scripts in the wiki.
Good luck!

Confusion: a Custom Story - Ch1 for play!
http://www.frictionalgames.com/forum/thread-15477.html
About 50% built.
Delayed for now though!
06-13-2012, 12:56 PM
Website Find




Users browsing this thread: 1 Guest(s)