Frictional Games Forum (read-only)
What would be the script for this? - 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: What would be the script for this? (/thread-15139.html)



What would be the script for this? - GetHimNotMe - 04-28-2012

I want to do it so the when you try to open a locked door it will display a message only when you have a certain item. For example, you try to open door. It says "it's locked" when you pick up a key and try to open the door again it would say "try using the key to open the door" instead. It would say "try using the key to open the door" only when you have the key. What script would you type for that? (I'm a newbie with scripting).


RE: What would be the script for this? - Cranky Old Man - 04-28-2012

(04-28-2012, 04:27 AM)GetHimNotMe Wrote: I want to do it so the when you try to open a locked door it will display a message only when you have a certain item. For example, you try to open door. It says "it's locked" when you pick up a key and try to open the door again it would say "try using the key to open the door" instead. It would say "try using the key to open the door" only when you have the key. What script would you type for that? (I'm a newbie with scripting).
You describe exactly what happens when you try to open a door in the first hub. Have you checked out how Frictional Games did it?
You can't except us to write an entire script for you, though. At least write as much of the script as you can, and we'll fill in the gaps.





RE: What would be the script for this? - Knittel - 04-28-2012

Tutorial for exactly what you need:
http://wiki.frictionalgames.com/hpl2/tutorials/script/adding_messages_to_locked_doors
Add in the script the following line:
Code:
void DoorLockedPlayer(string &in entity)
{
    if(GetSwingDoorLocked("EXAMPLE_DOOR") == true)
    {  if (HasItem("KEYNAME") == true) SetMessage("Messages", "msgnameA", 0);  else  SetMessage("Messages", "msgnameB", 0);
    }
}
And BTW, here is a complete Tutorial for Scripting etc. (in English)
http://www.frictionalgames.com/forum/thread-10798.html
Here would be a complete Tutorial (in German) for the complete editor instead of only scripting but not that extensive as the other tutorial:
http://www.youtube.com/watch?v=_sHYeUJ93qU&list=PL65ABEAAE26D4C289&index=1&feature=plpp_video



RE: What would be the script for this? - SilentStriker - 04-28-2012

(HasItem("KEYNAME") == true) should be (HasItem("KEYNAME")) since with the == true it will say if true then true



RE: What would be the script for this? - Cranky Old Man - 04-28-2012

(04-28-2012, 09:32 AM)SilentStriker Wrote: (HasItem("KEYNAME") == true) should be (HasItem("KEYNAME")) since with the == true it will say if true then true
Don't you mean "if true == true"? It's small matter of fewer characters versus readability. You're making it sound like an error.





RE: What would be the script for this? - SilentStriker - 04-28-2012

(04-28-2012, 01:49 PM)Cranky Old Man Wrote:
(04-28-2012, 09:32 AM)SilentStriker Wrote: (HasItem("KEYNAME") == true) should be (HasItem("KEYNAME")) since with the == true it will say if true then true
Don't you mean "if true == true"? It's small matter of fewer characters versus readability. You're making it sound like an error.
Well my english isn't flawless so I may have used the wrong words ^^ What I meen is that you don't need the == true since the if(HasItem("NAMEOFKEY")) already is a true statement Smile


RE: What would be the script for this? - Knittel - 04-28-2012

Normally and in all of my pascal programs I'm doing it also that way (if HasItem then), but I thought Amnesia would need it in that way (if HasItem == true).
Well thanks for telling. No I can save time :p