Frictional Games Forum (read-only)
Weird coding errors? - 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: Weird coding errors? (/thread-30525.html)



Weird coding errors? - goalreadymc - 09-07-2015

Hi,

I'm trying to script my HPS file and I keep getting weird crashes when I open my custom story, so I was wondering if anybody can check my code. Thank you!

Code:
void OnStart()
//
SetPlayerActive(false);
FadeOut(0);
AddTimer("", 1.4, "CoughTimer");
SetEntityPlayerInteractCallback("", "IntroCreditsDoor1", true);
AddEntityCollideCallback("LanternVeriMessage", "Player", "LanternVeriMessage", false, 1);

void CoughTimer(string &in asTimer)
//
PlaySoundAtEntity("", "player_cough.snt", "Player", 0.1f, false);
AddTimer("", 2.6, "WakeTimer");

void WakeTimer(string &in asTimer)
//
PlaySoundAtEntity("", "player_crouch.snt", "PLayer", 0.1f, false);
FadeOut(0.7);

void IntroCreditsDoor1(string &in asEntity)
//
SetMessage("IntroCredits", "Door1", 1.7);

void LanternVerification(string &in asItem, string &in asEntity)
//
SetEntityActive("LanternVeriBarrier", false);
SetEntityActive("LanternVeriMessage", false);

void LanternVeriMessage(string &in asParent, string &in asChild, int alState)
//
SetMessage("IntroCredits", "LanternVeriMessage", 1.7);



RE: Weird coding errors? - Mudbill - 09-07-2015

You're using double-slash instead of brackets? What?

No, a function looks like this:

PHP Code:
void MyFunc()
{



Not this:

PHP Code:
void MyFunc()
// 

Not sure where you got this from but that's your crash at least.


RE: Weird coding errors? - 7heDubz - 09-07-2015

For debugging your own code you can take the error code and find the corresponding (12,36) (line, character) is you get a line and a 0 for example, (12,0), try checking the line of code before it the one it returned with.

But yeah, you were way mistaken, the double forward slash is used for commenting lines of code. Brackets contain groupings of code such as the kind you find in a function.


RE: Weird coding errors? - SwingsDarkCreeps - 09-07-2015

hi, so this: //(double slash)- corresponds at commentaries inside the script(like 7he Dubz
said before);
{}(brackets)-corresponds at function branch or
offshoot (like Mugbill said before);
A functions usually start with a bracket and end with another bracket(exceptions if you don't use break function) like this:
void TheSpecificCallbackFunction(...)
{
here you write the code;
}
Wink
that is the general structure of a function;