Frictional Games Forum (read-only)
[SCRIPT] The books script - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] The books script (/thread-18643.html)



The books script - The chaser - 10-05-2012

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?


RE: The books script - Obliviator27 - 10-05-2012

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.


RE: The books script - Rapture - 10-05-2012

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); )


RE: The books script - The chaser - 10-05-2012

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?


RE: The books script - str4wberrypanic - 10-05-2012

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

The name of the books should be something like:

book_1, book_2, book_3...


RE: The books script - Adny - 10-05-2012

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!


RE: The books script - Kreekakon - 10-06-2012

(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.


RE: The books script - Adny - 10-06-2012

(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