Frictional Games Forum (read-only)
[SCRIPT] Im sure this is easier than i am making it... - 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] Im sure this is easier than i am making it... (/thread-17376.html)



Im sure this is easier than i am making it... - kevinsme2005isme13 - 07-31-2012

Please help! I have an error when i run my custom map. Its in the last line and character of this script, and i cant figure it out, please point me in the right direction. Thank you in advance!

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key_1", "door_1", "KeyOnDoor", true);
AddUseItemCallback("", "key_cabinet_1", "cabinet_1", "KeyOnDoor2", true);
AddUseItemCallback("", "exitkey_1", "exitdoor_1", "KeyOnDoor3", true);
AddUseItemCallback("", "exitkey_2", "exitdoor_2, "KeyOnDoor4", true);
AddUseItemCallback("", "exitkey_3", "exitdoor_3", "KeyOnDoor5", true);
AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunction1", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "MonsterFunction2", true, 1);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("key_1");
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("cabinet_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("key_cabinet_1");
}

void KeyOnDoor3(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("exitdoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "exitdoor_1", 0, false);
RemoveItem("exitkey_1");
}

void KeyOnDoor4(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("exitdoor_2", false, true);
PlaySoundAtEntity("", "unlock_door", "exitdoor_2", 0, false);
RemoveItem("exitkey_2");
}

void KeyOnDoor5(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("exitdoor_3", false, true);
PlaySoundAtEntity("", "unlock_door", "exitdoor_3", 0, false);
RemoveItem("exitkey_3");
}

void MonsterFunction1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("enemy_1", true);
SetSwingDoorLocked("trapdoor_1", true, true);
}

void MonsterFunction2(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("enemy_2", true);
SetSwingDoorLocked("trapdoor_1", true, true);
}
////////////////////////////
//Run when entering map
void OnEnter()
{

}

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

}



RE: Im sure this is easier than i am making it... - Kazakarumariou - 07-31-2012

It says it's the last line in the script, but it's really not. What's the error? is it "Unexpected end of file"?


RE: Im sure this is easier than i am making it... - Adny - 07-31-2012

AddUseItemCallback("", "exitkey_2", "exitdoor_2", "KeyOnDoor4", true); ///here

You were missing a quotation after "exitdoor_2".

In addition, I modified your callbacks a bit using some "shortcuts"; this will greatly reduce excess lines of script and make it less cluttered; be sure to remove all of the other functions for the keys/doors that aren't "UseKeyOnDoor". If you can't get this to work, you can just use the one fix I pointed out.



////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key_1", "door_1", "UseKeyOnDoor", true);
AddUseItemCallback("", "key_cabinet_1", "cabinet_1", "UseKeyOnDoor", true);
AddUseItemCallback("", "exitkey_1", "exitdoor_1", "UseKeyOnDoor", true);
AddUseItemCallback("", "exitkey_2", "exitdoor_2", "UseKeyOnDoor", true); ///here
AddUseItemCallback("", "exitkey_3", "exitdoor_3", "UseKeyOnDoor", true);
AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunction1", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "MonsterFunction2", true, 1);
}


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




void MonsterFunction1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("enemy_1", true);
SetSwingDoorLocked("trapdoor_1", true, true);
}


void MonsterFunction2(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("enemy_2", true);
SetSwingDoorLocked("trapdoor_1", true, true);
}


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


}


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


}
Hope that helped!


RE: Im sure this is easier than i am making it... - kevinsme2005isme13 - 07-31-2012

Ahh thank you very much! How silly of me to miss a quote. Also, thanks for helping clean up that script, it was looking quite messy. Its my first few hours into this, and i really do appreciate the help!