![]() |
Doors behave stangely - 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: Doors behave stangely (/thread-20832.html) |
Doors behave stangely - ingedoom - 03-20-2013 Hi forum. I have a problem that i hope you can help me solve. The problem is; that the OpenDoor() function doesn't seem to work when it's called from within a timer function (in this case IntroHalt()). The debug message "door opens" is sent but the door is not affected by the script. When i call the function from Onstart() or StartIntro() it works just fine and the door opens. I've also tried to put the door opening script inside the timer function itself, but this does not work either.. Do i have to make a ScriptArea for this to work, or can i do something else to avoid it? So i won't have to worry about adding areas in the level editor? Also, can you explain why i can't seem to call the door opening script from a timer? Spoiler below!
Edit: I tried to call the OpenDoor function with an EntityCollideCallback, but that didn't help either. I still only get the debug message Spoiler below!
RE: Calling functions from timers - The chaser - 03-20-2013 When making timers, the parameters (void Example ()) are always "string &in asTimer". So: Code: //====================== What are you exactly trying to achieve at the OpenDoor thing? I don't understand what you are trying to do. RE: Calling functions from timers - ingedoom - 03-20-2013 (03-20-2013, 05:53 PM)The chaser Wrote: When making timers, the parameters (void Example ()) are always "string &in asTimer". So:No they are not. "&in asTimer" can be changed to whatever you please. As i said, the timers work just fine. (03-20-2013, 05:53 PM)The chaser Wrote: What are you exactly trying to achieve at the OpenDoor thing? I don't understand what you are trying to do.OpenDoor is a self tailored function and is called from the IntroHalt timer fucntion, and is meant to open the door with the fuctions that are provided by the engine. RE: Calling home made functions - PutraenusAlivius - 03-21-2013 StartIntro() and OpenDoor() is NOT a func included in the game. Or maybe that some functions that was in the original game wasn't put in the Script Functions page. RE: Calling home made functions - ingedoom - 03-21-2013 (03-21-2013, 05:56 AM)JustAnotherPlayer Wrote: StartIntro() and OpenDoor() is NOT a func included in the game. Or maybe that some functions that was in the original game wasn't put in the Script Functions page. You can make your own functions. Just as i said StartIntro() calls the script inside void StartIntro() and starts the timers FadeIn and what not. My problem is that i can only seem to get the door opening script to work when i use it in the beginning of the map, (inside either OnStart() or StartIntro() ) which is really wierd. Go read the script language and reference guide if you have no clue how my script should work. It might clear out some misunderstandings. RE: Calling functions from timers - Adrianis - 03-22-2013 (03-20-2013, 06:01 PM)ingedoom Wrote:(03-20-2013, 05:53 PM)The chaser Wrote: When making timers, the parameters (void Example ()) are always "string &in asTimer". So:No they are not. "&in asTimer" can be changed to whatever you please. The '&' and 'in' are, seperately, both keywords used by AS. The name asTimer can change as that is just the name of the variable, and you can change &in too if you like but you shouldnt. string& is a string type that passes a memory address rather than the actual value to the function. Using &in means that the value of the variable cannot be modified, as opposed to say string &inout (or more simply string&) which would enable you to modify the value. Checkout this part of the AS manual, http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script_func_ref.html This line, Code: if(ScriptDebugOn() and ! HasItem("lantern")) I'm pretty sure that the cause of the issue is using void OpenDoor(string door) I'm surprised it doesn't cause an error, but it's likely not working because OpenDoor("prison_11"); is not passing the value correctly into the function - and because you use that string as the arguments for the rest of the calls in that function (rather than hard-coding it in) it may be just that it doesn't know what to open Try it out as Code: void OpenDoor(string &in door) If that fails, add or change the AddDebugMessage call in OpenDoor to print the value of the 'door' string so that we can see if it is the name causing the problem, or if there is something wrong with the rest of the calls in that function RE: Calling functions from timers - ingedoom - 03-22-2013 (03-22-2013, 12:29 PM)Adrianis Wrote: Checkout this part of the AS manual,Thx for &in explanation =) It ws really helpful. But it didn't solve the problem though. (03-22-2013, 12:29 PM)Adrianis Wrote: This line,You can use "and" instead of && just fine. =) (03-22-2013, 12:29 PM)Adrianis Wrote: If that fails, add or change the AddDebugMessage call in OpenDoor to print the value of the 'door' string so that we can see if it is the name causing the problem, or if there is something wrong with the rest of the calls in that function PHP Code: void OnStart() My problem seems to be that this: PHP Code: void CollideScriptArea_1(string &in ParentName, string &in ChildName, int alState) No matter what i do, the script beneath only works when i call it in the beginning, like in void OnStart(), but not when call it from somewhere else. ;/ PHP Code: SetSwingDoorDisableAutoClose(door, true); It is very strange. I hope you know what might be wrong. Okay i finally solved it.... There is nothing wrong with the script by the way, it is just the way doors behave that seem to be the problem. I found out that is i if i opened and closed the door, the opening script worked also when called inside the areacollison function. i solved it by simply setting the openstate to 0.1 in the level editor, and then in the beginning of the script make it close. That enabled my script to work. =) F**king doors srsly. RE: Doors behave stangely - Adrianis - 03-22-2013 Haha, brilliant... oh well. At least we all learned something ![]() |