Need help with a script (again) - 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 (https://www.frictionalgames.com/forum/forum-35.html) +--- Thread: Need help with a script (again) (/thread-4666.html) Pages:
1
2
|
Need help with a script (again) - Akasu - 09-22-2010 I've been trying to get this script to work for 2 hours now with no luck. It should make a light visible when a box is in the right place and make it invisible when it's not in place. void OnStart () { AddEntityCollideCallback("box1","area_red","BOX1RED", false, 1); } // Is this right? : "box1" is the object that should collide with the "area_red", "BOX1RED" is the script it runs when collided, "false" makes the script re-runnable, and "1" means that the "BOX1RED" runs on collide (-1 runs when they're not colliding) void BOX1RED(string &in asParent, string &in asChild, int alState) {if(asChild == "area_red") { SetLightVisible("redy", true); // "redy" is a pointlight } else SetLightVisible("redy", false); } I copied it from one of the main maps' scripts but it won't work. It simply does nothing (doesn't crash though) RE: Need help with a script (again) - gosseyn - 09-22-2010 you can just do Code: void BOX1RED(string &in asParent, string &in asChild, int alState) unless you have other boxes that needs colliding with the same area RE: Need help with a script (again) - Akasu - 09-22-2010 Yeah, I've got other boxes and areas. Just wanted to test with one first. RE: Need help with a script (again) - gosseyn - 09-22-2010 i mean, you can do as i told you, unless you want to handle all collisions inside one big function. But you can also make one function for each collision example, blue box and blue light : Code: void OnStart () Code: void BOX1BLUE(string &in asParent, string &in asChild, int alState) RE: Need help with a script (again) - Akasu - 09-22-2010 Yeah, sure but that doesn't solve the problem why the script doesn't work. Anyways, the bigger function would be more convenient. RE: Need help with a script (again) - gosseyn - 09-22-2010 maybe check the names RE: Need help with a script (again) - Akasu - 09-22-2010 Been there, done that. Could you test if it works RE: Need help with a script (again) - gosseyn - 09-22-2010 yes it works, i don't have to test it, i have many collision callbacks in my script RE: Need help with a script (again) - Akasu - 09-22-2010 Now it lights up but doesn't switch off when the box is removed.. Help? void OnStart () { SetLightVisible("redy", false); AddEntityCollideCallback("box1","area_red","BOX1RED", false, 1); } void BOX1RED(string &in asParent, string &in asChild, int alState) {if(asChild == "area_red") { SetLightVisible("redy", true); } else if (asChild != "area_red"){ SetLightVisible("redy", false); } } RE: Need help with a script (again) - Pandemoneus - 09-22-2010 It won't work, let me clarify it for you: Code: void OnStart () 1. the alState in AddEntityCollideCallback doesn't mean - "1" means that the "BOX1RED" runs on collide (-1 runs when they're not colliding) - it means alStates = 1=only call when entity enters, -1=only call when entity leaves 0=both 2. a solution to your problem I can think of is: Code: void OnStart () Could have made the script much easier if the game had local booleans though. |