HPS error (level editing) - 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: HPS error (level editing) (/thread-14037.html) Pages:
1
2
|
HPS error (level editing) - mrscoomich - 03-16-2012 //=========================================== // Starter's Script File! //=========================================== //=========================================== // This runs when the map first starts void OnStart() { if(ScriptDebugOn()) { GiveItemFromFile("lantern", "lantern.ent"); SetPlayerLampOil(100.0f); for(int i = 0;i < 10;i++) { GiveItemFromFile("tinderbox", "tinderbox.ent"); } } } //=========================================== // This runs when the player enters the map void OnEnter() { { AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("door_1", false, true); PlaySoundAtEntity("", "unlocked_door", "door_1", 0, false); RemoveItem("key_1"); } } //=========================================== // This runs when the player leaves the map void OnLeave() { } ------------------------------------------------------------------------------------------- Everytime I do a test run it says this: FATAL ERROR: Could not load script file 'maps/main/my_map.hps'! main (27, 8) : ERR : Expected '(' extra info: I use n++ and the language is set to c++ --- any way to fix this? RE: HPS error (level editing) - Adny - 03-16-2012 After looking at it, the only thing I can think of is to take the line: " AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);" Take it out of the void OnEnter(), and add it to void OnStart() You don't want all of your functions to be inside your onstart or onenter, you want them on their own, outside of it. For example,you have: void OnEnter() { { void your function(blahblah) } } But that is wrong ^^^^^^^^ It needs to be outside of it, so more like this: void OnEnter() { }
{ void yourfunction() }
From what limited knowledge I have of C++ and the Amnesia scripts, OnStart() should be used to add your callbacks, and set music lights, and OnEnter() should be used for autosaves, and preloading sounds and particle systems. Functions go anywhere else (except OnLeave)If you're ever in doubt, you can check the .hps files from the actual Amnesia game. Hope that helped. If I haven't made my point clear as I think I have, please P.M. me
RE: HPS error (level editing) - mrscoomich - 03-16-2012 this is what i've done. I did exactly what you said and even the other option u suggested but it's still not working. BTW: AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); <<<<< i think this one is really what's wrong. i have a feeling thats the only error there is and i dont know whether to change it, move it or what :/ ------ //=========================================== // Starter's Script File! //=========================================== //=========================================== // This runs when the map first starts void OnStart() { if(ScriptDebugOn()) { GiveItemFromFile("lantern", "lantern.ent"); SetPlayerLampOil(100.0f); for(int i = 0;i < 10;i++) { GiveItemFromFile("tinderbox", "tinderbox.ent"); } } AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); } //=========================================== // This runs when the player enters the map void OnEnter() { { } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("door_1", false, true); PlaySoundAtEntity("", "unlocked_door", "door_1", 0, false); RemoveItem("key_1"); } } //=========================================== // This runs when the player leaves the map void OnLeave() { } RE: HPS error (level editing) - Equil - 03-17-2012 Try having the "UseKeyOnDoor" function outside of OnEnter. Like this: Code: void OnStart() RE: HPS error (level editing) - mrscoomich - 03-17-2012 (03-17-2012, 01:59 AM)Equil Wrote: Try having the "UseKeyOnDoor" function outside of OnEnter. Like this: I did that just now. (copy and pasted)... this time it didn't crash but the door was left unlocked... ? RE: HPS error (level editing) - Equil - 03-17-2012 I assume you've ticked "Locked" on the door in the level editor then? If so, try putting SetSwingDoorLocked("door_1", true, true); in OnStart() RE: HPS error (level editing) - mrscoomich - 03-18-2012 errrmm.. no i didnt :\ I left it unlocked. EDIT: okay. here, i clicked the checkbox as LOCKED, changed it to true here is my script: *********************** void OnStart() { if(ScriptDebugOn()) { GiveItemFromFile("lantern", "lantern.ent"); SetPlayerLampOil(100.0f); for(int i = 0;i < 10;i++) { GiveItemFromFile("tinderbox", "tinderbox.ent"); } } AddUseItemCallback("", "key_1", "mansion_1", "UsedKeyOnDoor", true); SetSwingDoorLocked("mansion_1", true, true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { PlaySoundAtEntity("", "unlocked_door", "mansion_1", 0, false); RemoveItem("key_1"); } *********************** NOW the problem is, when I try to open the door without the key, it is locked. so thats good. but when i grab my key, and use it with the door , not ONLY does the key disappear but the door does not unlock. it stays closed like it was before ? this is my first time scripting and i have spent a week on learning this kind of programming so im sorry about that LOL. JUST wondering if there is something on the HPL2 program that I should write while im on the Entity tab of my mansion_1 RE: HPS error (level editing) - DaAinGame - 03-21-2012 Its because you never tell the door to actually unlock itself. void OnStart() { if(ScriptDebugOn()) { GiveItemFromFile("lantern", "lantern.ent"); SetPlayerLampOil(100.0f); for(int i = 0;i < 10;i++) { GiveItemFromFile("tinderbox", "tinderbox.ent"); } } AddUseItemCallback("", "key_1", "mansion_1", "UsedKeyOnDoor", true); SetSwingDoorLocked("mansion_1", true, true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_1", false, true); PlaySoundAtEntity("", "unlocked_door", "mansion_1", 0, false); RemoveItem("key_1"); } The green line is missing, which is why your door never unlocked. Hope it works now! RE: HPS error (level editing) - mrscoomich - 03-21-2012 It worked! THANKS =D .... but one problem.. the sound of the unlocked_door didnt play o.o RE: HPS error (level editing) - DaAinGame - 03-21-2012 (03-21-2012, 10:16 PM)mrscoomich Wrote: It worked! THANKS =DUse this: unlock_door.snt try |