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
3 books open door script
Lukaboy8 Offline
Junior Member

Posts: 25
Threads: 10
Joined: Aug 2012
Reputation: 0
#1
3 books open door script

Hello everybody,

I want a script in which you have to pull out 3 books out of the shelves withing 30 seconds to unlock a certain door. How can I make this?

Luke
08-04-2012, 04:37 PM
Find
EXAWOLT Offline
Member

Posts: 113
Threads: 14
Joined: Apr 2012
Reputation: 3
#2
RE: 3 books open door script

AddTimer(string& asName, float afTime, string& asFunction);
RemoveTimer(string& asName);

if timer runs out, use the removecallback func

simply nuff said




(This post was last modified: 08-04-2012, 04:54 PM by EXAWOLT.)
08-04-2012, 04:53 PM
Find
Lukaboy8 Offline
Junior Member

Posts: 25
Threads: 10
Joined: Aug 2012
Reputation: 0
#3
RE: 3 books open door script

I also want to know about how to pull out those books of courseWink
08-04-2012, 04:56 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#4
RE: 3 books open door script

First, make a small script area in front of each book (the book you should be using is under entities > gameplay, top of the list), be sure to place it so when the book is pulled all the way out, it will collide with the area. Now, here's the script (I did this pretty quickly, so I might've forgotten a thing or two):




void OnStart()
{
AddEntityCollideCallback("NAME_OF_BOOK_1", "NAME_OF_AREA_1", "BookFunc", false, 1);
AddEntityCollideCallback("NAME_OF_BOOK_2", "NAME_OF_AREA_3", "BookFunc", false, 1);
AddEntityCollideCallback("NAME_OF_BOOK_3", "NAME_OF_AREA_3", "BookFunc", false, 1);

SetLocalVarInt("BookVar", 0);
}

void BookFunc(string &in asParent, string &in asChild, int alState)
{
AddTimer("puzzletimer", 30.0f, "RestartPuzzle");

if(asParent == "NAME_OF_BOOK_1")
{
AddLocalVarInt("BookVar", 1);
GetPuzzleComplete();
}
if(asParent == "NAME_OF_BOOK_2")
{
AddLocalVarInt("BookVar", 1);
GetPuzzleComplete();
}
if(asParent == "NAME_OF_BOOK_3")
{
AddLocalVarInt("BookVar", 1);
GetPuzzleComplete();
}
}

void GetPuzzleComplete()
{
if(GetLocalVarInt("BookVar") == 3)
{
SetSwingDoorLocked("NAME_OF_DOOR", false, true);
RemoveTimer("puzzletimer");
}
}

void RestartPuzzle(string &in asTimer)
{
SetLocalVarInt("BookVar", 0);
SetMoveObjectState("NAME_OF_BOOK_1", 0);
SetMoveObjectState("NAME_OF_BOOK_2", 0);
SetMoveObjectState("NAME_OF_BOOK_3", 0);
}


Hope that helped!

I rate it 3 memes.
08-04-2012, 04:58 PM
Find
EXAWOLT Offline
Member

Posts: 113
Threads: 14
Joined: Apr 2012
Reputation: 3
#5
RE: 3 books open door script

there is a book that you always can pull out/in withous any scripts, then you can make a interact area with : AddPropForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
(the book will fall back when touching the area)
addtimer
then when you draw a new book, the callback should call: remove timer, and addcollidecallback
to enable callbacks for the next books

simply nuff said




08-04-2012, 05:04 PM
Find
Lukaboy8 Offline
Junior Member

Posts: 25
Threads: 10
Joined: Aug 2012
Reputation: 0
#6
RE: 3 books open door script

Thanks for the script andyrockin123! But there are some things I want to change in the script but I don't know how. I want the books to go back in the shelf if the puzzle isn't completed within 30 seconds and I want that you aren't able to push the book back in the shelf. This should only happen if it isn't completed after 30 seconds by itself. How can I make something like that?
08-05-2012, 12:27 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#7
RE: 3 books open door script

Just look in the original game they have the 3 book puzzle there.

08-05-2012, 12:32 PM
Find
Lukaboy8 Offline
Junior Member

Posts: 25
Threads: 10
Joined: Aug 2012
Reputation: 0
#8
RE: 3 books open door script

I don't know which script, where to find it and then which codes relate to what I want.
08-05-2012, 12:43 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#9
RE: 3 books open door script

Look in 03_Archives it has the script you want.

08-05-2012, 01:02 PM
Find
Lukaboy8 Offline
Junior Member

Posts: 25
Threads: 10
Joined: Aug 2012
Reputation: 0
#10
RE: 3 books open door script

Thanks! My script is done now and sounds are in it too!

EDIT: I got an error and it says unexpected and of file. This is my script:

PHP Code: (Select All)
void OnStart()
{
AddEntityCollideCallback("Book1""Bookarea1""Bookstart"false1);
AddEntityCollideCallback("Book2""Bookarea2""Bookstart"false1);
AddEntityCollideCallback("Book3""Bookarea3""Bookstart"false1);
SetLocalVarInt("BookVar"0); 
}
void Bookstart(string &in asParentstring &in asChildint alState)
{
AddTimer("Puzzletimer"30.0f"RestartPuzzle");
if(
asParent == "Book1")
{
AddLocalVarInt("BookAm"1);
SetPropObjectStuckState("Book1"1);
PlaySoundAtEntity("Book1Sound, "gameplay_tick", Book1, 0.0f, false);
GetPuzzleComplete();
}
if(asParent == "
Book2")
{
AddLocalVarInt("
BookAm", 1);
SetPropObjectStuckState("
Book2", 1);
PlaySoundAtEntity("
Book2Sound"gameplay_tick"Book20.0ffalse);
GetPuzzleComplete(); 
}
if(
asParent == "Book3")
{
AddLocalVarInt("BookAm"1);
SetPropObjectStuckState("Book3"1);
PlaySoundAtEntity("Book3Sound, "gameplay_tick", Book3, 0.0f, false);
GetPuzzleComplete(); 

}
void GetPuzzleComplete()
{
if(GetLocalVarInt("
BookAm") == 3)
{
SetSwingDoorLocked("
Librarydoor", false, true);
PlaySoundAtEntity("
BooksDone", "lock_door", "Player", 0, false);
RemoveTimer("
Puzzletimer");
}
}
void RestartPuzzle(string &in asTimer)
{
SetLocalVarInt("
BookAm", 0); 
SetPropObjectStuckState("
Book1", -1);
SetPropObjectStuckState("
Book2", -1);
SetPropObjectStuckState("
Book3", -1);
RemoveTimer("
Puzzletimer");
AddTimer("
Restarttimer", 1.0f, "RestartPuzzle2");
}
void RestartPuzzle2(string &in asTimer)
{
SetPropObjectStuckState("
Book1", 0);
SetPropObjectStuckState("
Book2", 0);
SetPropObjectStuckState("
Book3", 0);
RemoveTimer("
Restarttimer");

(This post was last modified: 08-05-2012, 03:59 PM by Lukaboy8.)
08-05-2012, 03:47 PM
Find




Users browsing this thread: 1 Guest(s)