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 The books script
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#1
The books script

So, I'm making a scene that requires a script. This is the situation:

For a reason I'm not going to tell, I want that when the books are touched (or the player grabs them and throws them) something happens.
The problem is, there are too much books, and making a single callback for each one would be a painful process.

Once I readed someone that wanted the same, more or less. I don't remember the thread, but I know it is something of for. How could I do it?

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
10-05-2012, 10:00 PM
Find
Obliviator27 Offline
Posting Freak

Posts: 792
Threads: 10
Joined: Jul 2011
Reputation: 66
#2
RE: The books script

for(int i = 1; i < 20; i++)SetEntityActive("Book_" + i, false);

Not tested, not 100 percent sure if that'll do it. Been doing modeling for the past little while and haven't been doing any scripting, so I'm a bit rusty.

Otherwise, you could use
SetEntityActive("Book_*". false);
That would make everything with the prefix of Book_ be affected by the script.

10-05-2012, 11:00 PM
Find
Rapture Offline
Posting Freak

Posts: 1,078
Threads: 79
Joined: May 2011
Reputation: 30
#3
RE: The books script

In the PlayerInteractCallBack (For the entity books). You can copy and paste the same function to call into each one. You'll just have to make sure each one is working.


So have a DebugMessage that pops up on each book interactcallback. (Make sure the callback is repeatable, the false or true option at the right.) And pick up every book to make sure they will all work.


Then do whatever you want. (i.e. @ Oblivator SetEntityActive("Book_*". false); )
(This post was last modified: 10-05-2012, 11:25 PM by Rapture.)
10-05-2012, 11:24 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#4
RE: The books script

Thanks, [b]Obliviator27 [/b]Rapture, but I'm not searching how to make a book not active, I'm searching that when this books collides with an area (or interacted, it must be decided) something happens.

So, I could do:

AddEntityCollideCallback("Book_1_", "//////...

And it would work for every book?

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
10-05-2012, 11:34 PM
Find
str4wberrypanic Offline
Member

Posts: 241
Threads: 24
Joined: Jul 2012
Reputation: 8
#5
RE: The books script

AddEntityCollideCallback("book_*", "Script_Area",
"Script", 1, true);

The name of the books should be something like:

book_1, book_2, book_3...

10-05-2012, 11:48 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#6
RE: The books script

Taking the ideas of Obliviator & str4wberry:

Spoiler below!


void OnStart()
{
for(int i=1;i<=20;++i)
AddEntityCollideCallback("Book_" + i, "NameOfArea", "Function", true, 1);
}

/*
The names of all books must be "Book_" + an integer
*/

void Function(string &in asParent, string &in asChild, int alState)
{
///Do Stuff
}


You can change the 20 to however many books there are; the only time consuming part of this would be naming the books in the level editor. Good luck!

I rate it 3 memes.
10-05-2012, 11:53 PM
Find
Kreekakon Offline
Pick a god and pray!

Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation: 124
#7
RE: The books script

(10-05-2012, 11:53 PM)andyrockin123 Wrote: You can change the 20 to however many books there are; the only time consuming part of this would be naming the books in the level editor. Good luck!
That still should be super simple, as anything named "blahblah_" with a number at the back will instantly chronologically increase that number whenever it is duplicated.

[Image: Tv0YgQb.gif]
Image by BandyGrass
10-06-2012, 03:46 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#8
RE: The books script

(10-06-2012, 03:46 AM)Kreekakon Wrote: That still should be super simple, as anything named "blahblah_" with a number at the back will instantly chronologically increase that number whenever it is duplicated.
I know, that statement was just to emphasize how easy it would be due to the "for" loop. Really useful scripting tidbit, beats writing out 20+ individual callbacks for sure :3

I rate it 3 memes.
10-06-2012, 04:00 AM
Find




Users browsing this thread: 1 Guest(s)