The chaser
Posting Freak
Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation:
113
|
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)
Aculy iz dolan.
|
|
10-05-2012, 10:00 PM |
|
Obliviator27
Posting Freak
Posts: 792
Threads: 10
Joined: Jul 2011
Reputation:
66
|
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 |
|
Rapture
Posting Freak
Posts: 1,078
Threads: 79
Joined: May 2011
Reputation:
30
|
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 |
|
The chaser
Posting Freak
Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation:
113
|
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)
Aculy iz dolan.
|
|
10-05-2012, 11:34 PM |
|
str4wberrypanic
Member
Posts: 241
Threads: 24
Joined: Jul 2012
Reputation:
8
|
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 |
|
Adny
Posting Freak
Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation:
173
|
RE: The books script
Taking the ideas of Obliviator & str4wberry:
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 |
|
Kreekakon
Pick a god and pray!
Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation:
124
|
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.
|
|
10-06-2012, 03:46 AM |
|
Adny
Posting Freak
Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation:
173
|
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 |
|
|