Frictional Games Forum (read-only)
Problems with coding / scripting for my custom story - 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: Problems with coding / scripting for my custom story (/thread-10817.html)



Problems with coding / scripting for my custom story - flakeguy - 10-17-2011

Hi! I've been inspired by PewDiePies adventures in various custom maps to create my own one and I have this perfect story I want to deliver! I was very proud of my first area in my custom map when I wanted to make a door, which required a key. The scripting went fine at first (note: this is my first attempt at coding, ever) untill some horrible error sign showed up, which I can't get rid of. Angry

Im sure something somewhere went wrong in my coding but I can't find it!

The error message is: "FATAL ERROR; could not load script customstories/Haunted/maps/Haunted.hps ERR: Expected '('

And I dont understand the .lang and .hps files. I have my extra_english.lang in customstories/haunted and TWO .hps files in customstories/haunted/maps

Please help me! Big Grin


This is what my Haunted.hps looks like:

My Haunted.hps looks like this:

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "firstkey_1", "firstdoor_1", "Usedfirstkey_1", true);
}
void Usedfirstkey_1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("firstdoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "firstdoor_1", 0, false);
RemoveItem("firstkey_1");
AddDebugMessage("Wrong", false);
}

void OnEnter()
{
}

void OnLeave
{
}

My Haunted.hps looks like this:

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "firstkey_1", "firstdoor_1", "Usedfirstkey_1", true);
}
void Usedfirstkey_1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("firstdoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "firstdoor_1", 0, false);
RemoveItem("firstkey_1");
AddDebugMessage("Wrong", false);
}

void OnEnter()
{
}

void OnLeave
{
}

[/quote]My extra_english.lang:

<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">You've just woken up and you don't know who you are, or where you are.[br]A note has been left, containing the very last few words of a mans life. Who was he?[br]It all starts from there. Good luck.</Entry>
</CATEGORY>

<CATEGORY Name="Journal">
<Entry Name="Note_letterone_Name">Greg, 1922</Entry>
<Entry Name="Note_letterone_Text">I can't stand this. Can't stand none of it.[br]Im sick and tired of all the flaws in this life.[br]I feel dirty. I still hear their screams and I still can't wash of the blood on my hands.[br]Farewell</Entry>
</CATEGORY>

<CATEGORY Name ="Inventory">
<Entry Name="ItemName_firstkey">Simple Key</Entry>
<Entry Name="ItemDesc_firstkey">A normal simple key, probably unlocks a wooden door.</Entry>
</CATEGORY>

</LANGUAGE>
And my second .hps file:

<CATEGORY Name="Journal">

<Entry Name="Note_Name_Name">Title</Entry>

<Entry Name="Note_Name_Text">Text</Entry>

</CATEGORY>

<CATEGORY Name ="Inventory">
<Entry Name="ItemName_name">Name</Entry>
<Entry Name="ItemDesc_name">Name</Entry>
</CATEGORY>




RE: Problems with coding / scripting for my custom story - Darion97 - 10-17-2011

This is true:

////////////////////////////
// Run when entering map
void OnStart()
{
AddUseItemCallback("", "firstkey_1", "firstdoor_1", "Usedfirstkey_1", true);
}
void Usedfirstkey_1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("firstdoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "firstdoor_1", 0, false);
RemoveItem("firstkey_1");
AddDebugMessage("Wrong", false);
}

void OnEnter()
{
}

void OnLeave()
{
}



RE: Problems with coding / scripting for my custom story - flakeguy - 10-17-2011

Wow, that was fast! Thanks. Unfortunately another FATAL ERROR appeared. "Could not load script file etc ERR: A Function with the same name and parameters already exists"


RE: Problems with coding / scripting for my custom story - Darion97 - 10-17-2011

Try this:

void OnStart()
{
AddUseItemCallback("", "firstkey_1", "firstdoor_1", "Usedfirstkey_1", true);
}
void Usedfirstkey_1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("firstdoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "firstdoor_1", 0, false);
RemoveItem("firstkey_1");
AddDebugMessage("Wrong", false);
}


RE: Problems with coding / scripting for my custom story - flakeguy - 10-17-2011

That actually worked! I'm so glad! Thank you very much, I've been trying to fix this for a really long time, you're awesome Darion