Scripting with if-clauses - 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: Scripting with if-clauses (/thread-9206.html) Pages:
1
2
|
Scripting with if-clauses - lemonpotatoe - 07-18-2011 Hey everyone, I'm completely new to scripting, which makes me a total noob. However, currently I'm stuck on a idea and I hope you can help me out. Here's what I wanna do: The player enters a room in which he can find the lantern. Once he has picked up the lantern and comes near the door, he walks into a script area which makes the door slam closed. The lantern item is called "lantern", the area is called "lanternarea", the door is called "lanternarea_door". Here's what I worked out so far: Code: void OnEnter() Where exactly did I go wrong? I hope someone can help me out. Cheers RE: Scripting with if-clauses - Tanshaydar - 07-18-2011 if statement checks something if it's true or not. So you don't need to check twice if it's true or not with HasItem("lantern")==true if(HasItem("lantern")) is enough. Again, you can try with deleting if line and see if the code actually works and nothing works with it, then try with if and pick up the lantern to see if it works. RE: Scripting with if-clauses - lemonpotatoe - 07-18-2011 Thanks for your reply. I removed the if-line and it worked perfectly. But once I added the if line it again didn't work. Maybe I entered the name "lantern" in the wrong fields? I've entered it in General > Name, Entity > CallbackFunc and Entity > PlayerInteractCallback. RE: Scripting with if-clauses - Tanshaydar - 07-18-2011 It should be entity's name. RE: Scripting with if-clauses - ThePaSch - 07-18-2011 (07-18-2011, 03:29 AM)lemonpotatoe Wrote: Maybe I entered the name "lantern" in the wrong fields? I've entered it in General > Name, Entity > CallbackFunc and Entity > PlayerInteractCallback. You don't put the entity's name into CallbackFunc and PlayerInteractCallback. These fields are for what their name suggests they are, for callbacks. Just like the callback you set up when the player and the area collide. For the record, you didn't include the quotation marks at General > Name, did you? RE: Scripting with if-clauses - lemonpotatoe - 07-18-2011 OK, I removed the name from the other fields, so it's just in General > Name. I did not include the quotation marks in the field. However, it still doesn't work. Any ideas? RE: Scripting with if-clauses - Tanshaydar - 07-18-2011 General->Name-> Lantern if(HasItem("Lantern")) RE: Scripting with if-clauses - lemonpotatoe - 07-18-2011 (07-18-2011, 09:49 AM)Tanshaydar Wrote: General->Name-> LanternThat's what I did, but it doesn't work. RE: Scripting with if-clauses - Tanshaydar - 07-18-2011 When you picked up the lantern, you go into area and nothing happens? RE: Scripting with if-clauses - lemonpotatoe - 07-18-2011 (07-18-2011, 10:20 AM)Tanshaydar Wrote: When you picked up the lantern, you go into area and nothing happens? Exactly. But, as said before, once I remove the if-clause the script works perfectly, which tells me that there is either something wrong with the if clause or (more likely) with my item name. |