How make this script? (SOLVED) - 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: How make this script? (SOLVED) (/thread-38711.html) |
How make this script? (SOLVED) - Abihishi - 02-14-2016 Hi Guys! So, my question is - how make script when my character says *text*, when i enter in script area (box). It will be his thought. Thanks for all help tips Bye! RE: How make this script? - Mudbill - 02-14-2016 I understand you want some text to appear when the character walks into an area? That should be simple. First, create the ScriptArea in your level. In your script, within your OnStart function, add a collision callback between the player and the area, like so: PHP Code: void OnStart() Make sure "ScriptArea" matches the name of your in-level area. "CallbackName" can be whatever as long as it matches below. Below that, create the callback which tells the script what will happen when these two collide. Use SetMessage to display some text in the middle of the screen. PHP Code: void CallbackName(string &in asParent, string &in asChild, int alState) "MessageCategory" refers to a category within your extra_english.lang file. "MessageEntry" refers to an entry within that category. Are you familiar with the lang file? It should look somewhat like this in your lang file, but you might already have some of it. If that's the case, exclude it from here: PHP Code: <LANGUAGE> Most likely you already have the <LANGUAGE> tags in your lang file. If so, don't add them again. RE: How make this script? - Abihishi - 02-14-2016 Mmm.... where is wrong? https://scr.hu/0unb/cqb3l This AddUseItemCallback is other script. RE: How make this script? - Romulator - 02-14-2016 The error is the location of your CollideCallback, since it's not within a void, it will be considered an error. Since you're using rather simple code, having it in OnStart() is perfectly valid. Therefore, to put your AddEntityCollideCallback into the OnStart parentheses, we do something like the following; PHP Code: void OnStart() Make sure to change CallbackName to the name of your callback as well, which in this case, is Skyrpt1, since that is defined in your AddEntityCollideCallback(). Also, welcome to the forums! Just a friendly reminder to post any coding issues with Amnesia in the Development Support subforum. I have moved the thread over to there now. RE: How make this script? - Mudbill - 02-14-2016 Since you already have an OnStart function, you need to place the AddEntityCollideCallback line inside its brackets. You can't have a new script block without a heading. Ninja'd RE: How make this script? - Abihishi - 02-14-2016 Ok, i have this: void OnStart() { AddUseItemCallback("", "key1", "door1", "UseKeyOnDoor", true); AddEntityCollideCallback("ScriptArea", "Player", "Skrypt1", true, 1); } In game my script area is Skrypt 1, but this not work. In lang file i have: <CATEGORY Name="CategoryName"> <Entry Name="EntryName">My Text</Entry> </CATEGORY> @edit sorry for me, but i am completely green in scripts RE: How make this script? - Mudbill - 02-14-2016 Could you post your whole script? RE: How make this script? - Abihishi - 02-14-2016 This is all script file: void OnStart() { AddUseItemCallback("", "key1", "door1", "UseKeyOnDoor", true); AddEntityCollideCallback("ScriptArea", "Player", "Skrypt1", true, 1); } void CallbackName(string &in asParent, string &in asChild, int alState) { SetMessage("MessageCategory", "MessageEntry", 0); } void UseKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false); RemoveItem(asItem); SetLocalVarInt("Switch", 1); CompleteQuest("door1", "mementos1"); } void TouchDoor(string &in asEntity) { if(GetLocalVarInt("Switch") == 0) { AddQuest("door1", "mementos1"); } } And Lang (i no write my text, you know ) <CATEGORY Name="CustomStoryMain"> <Entry Name="Description"> Description custom story </Entry> </CATEGORY> ----------Notatki/Myśli---------- <CATEGORY Name="Journal"> <Entry Name="Note_voice_Name">Name Note</Entry> <Entry Name="Note_voice_Text">[voice Voice1.ogg][br] Text</Entry> <Entry Name="Quest_mementos1_Text">I must find key in bathroom.</Entry> </CATEGORY> ----------Nazwy I Opisy Przedmiotów---------- <CATEGORY Name="Inventory"> <Entry Name="ItemName_KeyDesc"> Bathroom Key</Entry> <Entry Name="ItemDesc_KeyDesc"> Old, dusty key. Used of peple thereof manor house.</Entry> </CATEGORY> <CATEGORY Name="CategoryName"> <Entry Name="EntryName">My text</Entry> </CATEGORY> </LANGUAGE> RE: How make this script? - Mudbill - 02-14-2016 You must change the name of this callback to match what you put inside the AddEntityCollideCallback(); PHP Code: void CallbackName(string &in asParent, string &in asChild, int alState) So make it like so: PHP Code: void Scrypt1(string &in asParent, string &in asChild, int alState) RE: How make this script? - Abihishi - 02-15-2016 I have: void OnStart() { AddUseItemCallback("", "key1", "door1", "UseKeyOnDoor", true); AddEntityCollideCallback("Player", "ScriptArea", "Scrypt1", true, 1); } void Scrypt1(string &in asParent, string &in asChild, int alState) { SetMessage("MessageCategory", "MessageEntry", 0); } But this not work in game. |