![]() |
Problem with door closing - 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: Problem with door closing (/thread-26750.html) |
Problem with door closing - Spazatron - 10-13-2014 I have a script where if the player goes through an area where a door is, and has certain items in their inventory, the door will close and lock itself behind them. When they go through the area, I'm using HasItem(); to check that they have the items, but the door doesn't close or lock. My code: Code: void OnStart() RE: Problem with door closing - FlawlessHappiness - 10-13-2014 You've got the idea, but you forgot to check if it's true or false that you have it... if you go here: http://wiki.frictionalgames.com/hpl2/amnesia/script_functions You'll notice that "HasItem" requires a bool. (It says 'bool' to the left of it). A bool is either "true" or "false". So, to make your script correct, it should look like this. PHP Code: void OnStart() This should work. I also added some adjustments RE: Problem with door closing - Spazatron - 10-13-2014 (10-13-2014, 05:39 PM)FlawlessHappiness Wrote: You've got the idea, but you forgot to check if it's true or false that you have it... Thanks for the reply. I corrected the code, but it still isn't working. The door also behaves strangely after I enter the area that should lock it. It only lets me grab the door in certain places at the top of the door while (I think) I'm inside the script area. :S EDIT: I'm so stupid. I made a typo on one of the entity's names. Sorry for the inconvenience XD Fixed it. RE: Problem with door closing - FlawlessHappiness - 10-13-2014 So everything works? RE: Problem with door closing - Mudbill - 10-13-2014 Just as a side note, the original boolean statements were correct. You don't explicitly need to define a true or false to the boolean in question. If undefined, it assumes true. Another way of doing false would be do to PHP Code: if(!HasItem("Name")) RE: Problem with door closing - MrBehemoth - 10-13-2014 (10-13-2014, 09:33 PM)Mudbill Wrote: Just as a side note, the original boolean statements were correct. You don't explicitly need to define a true or false to the boolean in question. If undefined, it assumes true. Another way of doing false would be do to This. Actually, the reason this works is because the "if" statement is checking whether the whole condition (the entire contents of the brackets) works out as "true", eg: Code: if(true) ...are all different ways of saying "if(true)", and the condition would pass. RE: Problem with door closing - Mudbill - 10-13-2014 ^ Good points. RE: Problem with door closing - FlawlessHappiness - 10-13-2014 So eh... That means it was all correct from the beginning? How come it worked when he put " == true" on it then...? Maybe because of the "Adjustments" I made... Not sure. RE: Problem with door closing - MrBehemoth - 10-13-2014 (10-13-2014, 06:03 PM)NickD Wrote: EDIT: I'm so stupid. I made a typo on one of the entity's names. Sorry for the inconvenience XD I guess that was the problem all along. RE: Problem with door closing - FlawlessHappiness - 10-14-2014 (10-13-2014, 11:48 PM)MrBehemoth Wrote:(10-13-2014, 06:03 PM)NickD Wrote: EDIT: I'm so stupid. I made a typo on one of the entity's names. Sorry for the inconvenience XD Haha! ^-^ Oh well, I learned stuff! Thank you! |