Frictional Games Forum (read-only)

Full Version: The books script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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.
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); )
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?
AddEntityCollideCallback("book_*", "Script_Area",
"Script", 1, true);

The name of the books should be something like:

book_1, book_2, book_3...
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!
(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.
(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