| Next revision | Previous revision | ||
|
hpl2:tutorials:script:adding_messages_to_locked_doors [2012/03/15 11:03] claypigeon created |
hpl2:tutorials:script:adding_messages_to_locked_doors [2014/07/04 11:21] (current) romulator Fixed the quotation mark issues. |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Adding messages to a locked door ====== | ====== Adding messages to a locked door ====== | ||
| - | |||
| Hey, in this tutorial me, ClayPigeon, will teach you how to add a message to a locked door. | Hey, in this tutorial me, ClayPigeon, will teach you how to add a message to a locked door. | ||
| - | |||
| What does this means? That means that when a player tries to open a locked door, it will show a message on the screen telling him it's locked, or will give the player a hint on where the key is. | What does this means? That means that when a player tries to open a locked door, it will show a message on the screen telling him it's locked, or will give the player a hint on where the key is. | ||
| - | |||
| ====== The message ====== | ====== The message ====== | ||
| - | |||
| First of all, open up your extra_english.lang file, and add this: | First of all, open up your extra_english.lang file, and add this: | ||
| - | |||
| <CATEGORY Name="Messages"> | <CATEGORY Name="Messages"> | ||
| - | + | <Entry Name ="msgname">TYPE MESSAGE HERE</Entry> | |
| - | <Entry Name ="msgname">TYPE MESSAGE HERE</Entry> | + | |
| </CATEGORY> | </CATEGORY> | ||
| - | |||
| msgname - The name that will be called via the script and present the message TYPE MESSAGE HERE. | msgname - The name that will be called via the script and present the message TYPE MESSAGE HERE. | ||
| - | |||
| TYPE MESSAGE HERE - The actual text that will be presented. It can be anything, for example: The door is locked, and the key is behind the cabinet. | TYPE MESSAGE HERE - The actual text that will be presented. It can be anything, for example: The door is locked, and the key is behind the cabinet. | ||
| - | + | ====== The door ====== | |
| - | The door | + | |
| Open up your map with your level editor, and add a door wherever you want. | Open up your map with your level editor, and add a door wherever you want. | ||
| - | |||
| Select the door using the Select tool(1), and go to the Entity tab. (Next to general). | Select the door using the Select tool(1), and go to the Entity tab. (Next to general). | ||
| - | |||
| Tick the 'Locked' box to make the door locked, and on the PlayerInteractCallback write whatever name of function you want. | Tick the 'Locked' box to make the door locked, and on the PlayerInteractCallback write whatever name of function you want. | ||
| - | |||
| I'll call it DoorLockedPlayer. | I'll call it DoorLockedPlayer. | ||
| - | |||
| If you want the message to show only once, tick the PlayerInteractCallbackAutoRemove box. | If you want the message to show only once, tick the PlayerInteractCallbackAutoRemove box. | ||
| + | Under General tab, name the door to whatever you want. | ||
| + | |||
| + | I'll call it “EXAMPLE_DOOR”. | ||
| + | |||
| + | {{http://oi43.tinypic.com/656cs3.jpg?nolink&}} | ||
| ====== The script ====== | ====== The script ====== | ||
| - | |||
| Open up your mapname.hps that is on your AmnesiaFolder/redist/custom_stories/yourstory/maps, with notepad++ or whatever editor that fits for you, and now write this under the last '}' you see on the text: | Open up your mapname.hps that is on your AmnesiaFolder/redist/custom_stories/yourstory/maps, with notepad++ or whatever editor that fits for you, and now write this under the last '}' you see on the text: | ||
| - | + | <code c++>void DoorLockedPlayer(string &in entity) | |
| - | void DoorLockedPlayer(string &in entity) | + | |
| { | { | ||
| + | if(GetSwingDoorLocked("EXAMPLE_DOOR") == true) | ||
| + | { | ||
| + | SetMessage("Messages", "msgname", 0); | ||
| - | SetMessage("Messages", "msgname", 0); | + | } |
| - | + | ||
| } | } | ||
| + | </code> | ||
| Now step by step: | Now step by step: | ||
| + | void DoorLockedPlayer - this is the function that is called when the player interacts with the door (the one you've set in your level editor!) | ||
| - | void DoorLockedPlayer - this is the function that is called when the player interacts with the door | + | GetSwingDoorLocked - We are checking wheter the doors is locked or not, so we won't get the message even when it's unlocked and interacted with. "EXAMPLE_DOOR" is the name of the door that we have given it earlier! |
| "Messages" - that is the <CATEGORY> name in your extra_english.lang file, DO NOT change this! | "Messages" - that is the <CATEGORY> name in your extra_english.lang file, DO NOT change this! | ||
| - | + | "msgname" - this is the name of the message we've set earlier, remember? | |
| - | "msgname" - this is the name of the message we've set earlier, remember? | + | |
| Now the message will display when the player is trying to open the door! | Now the message will display when the player is trying to open the door! | ||
| - | |||
| PM me for any help, my forum account: ClayPigeon. | PM me for any help, my forum account: ClayPigeon. | ||
| - | |||
| - | |||
| - | {{http://imageupload.org/en/file/200699/wiki.png.html}} | ||