![]() |
multiple script problem!!! - 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: multiple script problem!!! (/thread-6561.html) |
multiple script problem!!! - muminmuffin - 02-12-2011 hi there im kinda new to scripting, but i have managed to learn alot of scripting, but i need help with one thing, this is my script: void OnStart() { AddUseItemCallback("", "awesomekey_1", "awesomedoor_1", "UsedKeyOnDoor", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("awesomedoor_1", false, true); PlaySoundAtEntity("", "unlock_door", "awesomedoor_1", 0, false); RemoveItem("awesomekey_1"); } just a regular key-to-door script, but if i want to put another door script that is just the same, then what do i need to write between these so the game understands that its two different script?? do i need to write ''void..'' and then what?? plz help. RE: multiple script problem!!! - Urkle - 02-12-2011 Is this for Penumbra or Amnesia? Anyways the "AddUseItemCallBack" line is registering a callback to call the function "UsedKeyOnDoor" for key1 and door1. So, an easy way would be create a second function and register door2 to use that function as the callback. If this is for Amnesia, the use the custom stories forum for help. RE: multiple script problem!!! - muminmuffin - 02-12-2011 it is for amnesia. and yes i have renamed the doornames and all that, i just need help with this, and this is not just for especially this script, but for all. if i write the first example script here: void OnStart() { AddUseItemCallback("", "awesomekey_1", "awesomedoor_1", "UsedKeyOnDoor", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("awesomedoor_1", false, true); PlaySoundAtEntity("", "unlock_door", "awesomedoor_1", 0, false); RemoveItem("awesomekey_1"); } <----then do i need to write something special arround this line?? like {} or something like that to hold the two appart? cause i have tried to just start at the line beneath but then the game says :unexpected.. blabla and then ''{''?? how do i write them two next to each other? void OnStart() { AddUseItemCallback("", "awesomekey_2", "awesomedoor_2", "UsedKeyOnDoor", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("awesomedoor_2", false, true); PlaySoundAtEntity("", "unlock_door", "awesomedoor_1", 0, false); RemoveItem("awesomekey_2"); } RE: multiple script problem!!! - Oscar House - 02-12-2011 Just add the second Callback in the OnStart function and make a function for the callback, like this: Code: void OnStart() RE: multiple script problem!!! - muminmuffin - 02-12-2011 thanks a thousand!!! RE: multiple script problem!!! - Fireintex - 11-09-2011 Hey ive got a similar problem and its really starting to piss me off. ive already done those doors and keys correctly and they work fine, but what do i put after this: void OnStart() { AddUseItemCallback("", "torture_1", "castle_1", "KeyOnDoor1", true); AddUseItemCallback("", "tomb", "mansion_1", "KeyOnDoor2", true); } void KeyOnDoor1(string &in asItem, string &in asEntity) { SetSwingDoorLocked("castle_1", false, true); PlaySoundAtEntity("", "unlock_door.snt", "castle_1", 0.0f, true); RemoveItem("torture_1"); } void KeyOnDoor2(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_1", false, true); PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true); RemoveItem("tomb"); } void OnLeave() { } when i want to put something else in like an area script or another script that isnt to do with keys and doors, if anyone can help ill be so happy > ![]() RE: multiple script problem!!! - Tanshaydar - 11-09-2011 Is this for Amnesia custom story development? If so, why the hell it is in OPEN SOURCE COLLABORATION?! RE: multiple script problem!!! - 5BitHero - 06-14-2013 Can Someone help me ?! i need these two scripts to be in the same file ive seperated the scripts with this V ---------------------------------------------------------------------- void OnStart() { AddEntityCollideCallback("Player", "Jumpscare_1", "Jump1", true, 1); } void Jump1(string &in asParent, string &in asChild, int alState) { PlaySoundAtEntity("", "21_intro_scream.snt", "bro_1", 0, false); SetEntityActive("bro_1", true); AddTimer("", 1.0, "scared"); } void scared(string &in asTimer) { PlaySoundAtEntity("", "21_scream10(.ogg)", "Player", 0, false); SetEntityActive("bro_1", false); } ----------------------------------------------------------------------- void OnStart() { AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true); } void UseKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false); RemoveItem(asItem); } RE: multiple script problem!!! - VeNoMzTeamHysterical - 06-14-2013 (06-14-2013, 09:15 PM)5BitHero Wrote: Can Someone help me ?! Why did you bump up a 2 year old threat? You could instead make a new one! Script in this spoiler Spoiler below!
RE: multiple script problem!!! - PutraenusAlivius - 06-15-2013 Code: void OnStart() Y U BUMP THRED?! Anyway, here's the fixed script. Anything wrong is pinpointed in the script itself. EDIT: After re-reading it, it looks like you're going to make a dead body lunge to the Player. Please don't do that. Most people here doesn't like the "Flying Naked Guy" or "Flying Jesus". |