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
How to activate a 'Puzzle completed' script
Quotentote Offline
Member

Posts: 118
Threads: 23
Joined: Dec 2011
Reputation: 11
#1
How to activate a 'Puzzle completed' script

PHP Code: (Select All)
void OnStart()
{

AddEntityCollideCallback("book_01""bookarea_1""book1"true1);
AddEntityCollideCallback("book_02""bookarea_1""book2"true1);

///BOOKS
void book1(string &in asParentstring &in asChildint alState)
{
SetEntityActive("book_01"false);
SetEntityActive("book_001"true);
PlayGuiSound("impact_book_med1.ogg",10.0f);
}
void book2(string &in asParentstring &in asChildint alState)
{
SetEntityActive("book_02"false);
SetEntityActive("book_002"true);
PlayGuiSound("impact_book_med2.ogg",10.0f);


How do i activate the 'puzzle completed' script (like spawning a key or something)
the player has no regular order to do it (so he could do the book2 thing first, then book1)

greetings
(This post was last modified: 01-20-2012, 09:50 AM by Quotentote.)
01-20-2012, 09:18 AM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#2
RE: How to activate a 'Puzzle completed' script

(01-20-2012, 09:18 AM)Quotentote Wrote:
PHP Code: (Select All)
void OnStart()
{

AddEntityCollideCallback("book_01""bookarea_1""book1"true1);
AddEntityCollideCallback("book_02""bookarea_1""book2"true1);

///BOOKS
void book1(string &in asParentstring &in asChildint alState)
{
SetEntityActive("book_01"false);
SetEntityActive("book_001"true);
PlayGuiSound("impact_book_med1.ogg",10.0f);
}
void book2(string &in asParentstring &in asChildint alState)
{
SetEntityActive("book_02"false);
SetEntityActive("book_002"true);
PlayGuiSound("impact_book_med2.ogg",10.0f);


How do i activate the 'puzzle completed' script (like spawning a key or something)
the player has no regular order to do it (so he could do the book2 thing first, then book1)

greetings
Do you mean you want book 1 to be put in first, then book 2?

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
01-20-2012, 09:20 AM
Find
Quotentote Offline
Member

Posts: 118
Threads: 23
Joined: Dec 2011
Reputation: 11
#3
RE: How to activate a 'Puzzle completed' script

no. he can do it random. i just need a help with the check function: when every book is placed (no matter in what order) i want to start a new script
01-20-2012, 09:23 AM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#4
RE: How to activate a 'Puzzle completed' script

Ok, give me a minute of testing

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
01-20-2012, 09:25 AM
Find
Quotentote Offline
Member

Posts: 118
Threads: 23
Joined: Dec 2011
Reputation: 11
#5
RE: How to activate a 'Puzzle completed' script

(01-20-2012, 09:25 AM)Tripication Wrote: Ok, give me a minute of testing
okay Smile

01-20-2012, 09:31 AM
Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#6
RE: How to activate a 'Puzzle completed' script

Make a new function with the complete script in it. Then place the function inside an if-statement for every book collide areas.

Example:

PHP Code: (Select All)
void BookComplete()
{
    
Blahblah events..
}

void BookCol1(string &in...)
{
    if(
== 1)
{
    
BookComplete();
}


That's how I do it. Wink

Creator of The Dark Treasure.
(This post was last modified: 01-20-2012, 09:37 AM by Linus Ågren.)
01-20-2012, 09:37 AM
Website Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#7
RE: How to activate a 'Puzzle completed' script

Ok, i've done it.


void OnStart()
{
AddEntityCollideCallback("Player", "bookarea_1", "book1", true, 1);
AddEntityCollideCallback("book_02", "bookarea_1", "book2", true, 1);
SetLocalVarInt("Var01", 0); //THIS MAKES A COUNTER
}


void book1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("book_01", false);
SetEntityActive("book_001", true);
PlayGuiSound("impact_book_med1.ogg",10.0f);
AddLocalVarInt("Var01", 1); //THIS ADDS 1 TO THE COUNTER
if (GetLocalVarInt("Var01") == 2) //THIS CHECKS IF THE COUNTER =2
{
[CODE IN HERE]
}
}

void book2(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("book_02", false);
SetEntityActive("book_002", true);
PlayGuiSound("impact_book_med2.ogg",10.0f);
AddLocalVarInt("Var01", 1); //THIS ADDS 1 TO THE COUNTER
if (GetLocalVarInt("Var01") == 2)//THIS CHECKS IF THE COUNTER =2
{
[SAME CODE IN HERE]
}
}

Probably not the most efficient way, but it works.

When the "Counter" = 2, it will call whatever you have in the CODE IN HERE or SAME CODE IN HERE space.
NOTE: WHAT EVER GOES IN THE FIRST CODE SECTION, ALSO GOES IN THE OTHER, WORD FOR WORD OR IT PROBABLY WILL NOT WORK!

Also, http://wiki.frictionalgames.com/hpl2/tut...lvariables (tells you how to use variables)

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
(This post was last modified: 01-20-2012, 09:54 AM by Tripication.)
01-20-2012, 09:42 AM
Find
Quotentote Offline
Member

Posts: 118
Threads: 23
Joined: Dec 2011
Reputation: 11
#8
RE: How to activate a 'Puzzle completed' script

thank you guys, i guess...ehm i hope i will get it now Big Grin <3
01-20-2012, 09:49 AM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#9
RE: How to activate a 'Puzzle completed' script

(01-20-2012, 09:49 AM)Quotentote Wrote: thank you guys, i guess...ehm i hope i will get it now Big Grin <3



If you just read through this tutorial.
http://wiki.frictionalgames.com/hpl2/tut...lvariables


It will eventually sink in. Very useful when it comes to puzzles Big Grin

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
01-20-2012, 09:53 AM
Find
Quotentote Offline
Member

Posts: 118
Threads: 23
Joined: Dec 2011
Reputation: 11
#10
RE: How to activate a 'Puzzle completed' script

reading this right now ^^ well...as i said i hope i will get it ;D
01-20-2012, 09:57 AM
Find




Users browsing this thread: 4 Guest(s)