Frictional Games Forum (read-only)
[SCRIPT] Error at unlocking door with an item - 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: [SCRIPT] Error at unlocking door with an item (/thread-16817.html)



Error at unlocking door with an item - KingCrimson - 07-07-2012

It says:

"FATAL ERROR: main (21,23) : ERR : Expected identifier"

This is a copy of the .hps file:


Quote:////////////////////////////
// Run when the map starts
void OnStart()
{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("door2", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false);

PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}

AddUseItemCallback("", "secret1", "lckd", "unlock", true);

void unlock(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(lckd, false, true);
PlaySoundAtEntity("", "unlock_door", door, 0, false);
RemoveItem(secret1);
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
secret1 = Key name
lckd = Locked door name

PS: I don't know if it might have something to do with the error. But the key you must use, you get it on the level before this one.


RE: Error at unlocking door with an item - Cruzore - 07-07-2012

AddUseItemCallback("", "secret1", "lckd", "unlock", true);
It's in no function. It will never be called(that's why that error is there).


RE: Error at unlocking door with an item - KingCrimson - 07-07-2012

(07-07-2012, 10:40 PM)FastHunteR Wrote: AddUseItemCallback("", "secret1", "lckd", "unlock", true);
It's in no function. It will never be called(that's why that error is there).
I don't understand. I've already been nearly thirty minutes trying to fix this script and i think i'll get mad. Would you please correct my script and paste it in a reply?

Thanks in advance


RE: Error at unlocking door with an item - Cruzore - 07-07-2012

I have no idea when you plan to add that callback, since I can't read your mind. Cut that line of it out and paste it, I assume under OnStart().


RE: Error at unlocking door with an item - KingCrimson - 07-07-2012

I finally could make it work. Thanks, what you said was right, but i didn't understand it well. So the problem's solved. Thanks again for the help


RE: Error at unlocking door with an item - FlawlessHappiness - 07-08-2012

also
RemoveItem(secret1); should be
RemoveItem("secret1"); shouldn't it?


RE: Error at unlocking door with an item - KingCrimson - 07-08-2012

(07-08-2012, 12:11 AM)beecake Wrote: also
RemoveItem(secret1); should be
RemoveItem("secret1"); shouldn't it?
I've actually left it as
Quote: RemoveItem(asItem);
and it's working perfectly