Frictional Games Forum (read-only)
[SCRIPT] Error with scripts - 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 with scripts (/thread-29502.html)



Error with scripts - MaksoPL - 01-15-2015

Hi. I've got an error with a script:
main (10,1) Unexpected token '{'
main (15,16) Expected identifier
main (16,1) Unexpected token '}'

My .hps file:

void OnStart()
{
SetSanityDrainDisabled(true);

GiveItemFromFile("lantern", "lantern.ent");

for(int i=0;i< 25;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
}

{
AddEntityCollideCallback("Player", "12_girl_scream", "GirlScream", true, 1);
AddEntityCollideCallback("Player", "message1", "Message1", true, 1);
AddEntityCollideCallback("Player", "message2", "Message2", true, 1);
}
PlaySoundAtArea("12_girl_scream", "12_girl_scream.snt", "GirlScream01", 0, false);
}
void Message1(string &in asChild, string &in asParent, int alState)
{
SetMessage("Messages", "Wiadomosc1", 10);
}

void Message2(string &in asChild, string &in asParent, int alState)
{
SetMessage("Messages", "Wiadomosc2", 10);
}

void OnEnter()
{
PlayMusic("07_amb", true, 1.0f, 4.0f, 1, true);

}
What i've must do?


RE: Error with scripts - DnALANGE - 01-15-2015

Do like this;

PHP Code:
void OnStart()
 { 
 
SetSanityDrainDisabled(true);

 
GiveItemFromFile("lantern""lantern.ent");

 for(
int i=0;i25;i++) GiveItemFromFile("tinderbox_"+i"tinderbox.ent");

 
AddEntityCollideCallback("Player""12_girl_scream""GirlScream"true1);
 
AddEntityCollideCallback("Player""message1""Message1"true1);
 
AddEntityCollideCallback("Player""message2""Message2"true1);


 }

void GirlScream(string &in asParentstring &in asChildint alState)
{
PlaySoundAtEntity("12_girl_scream""12_girl_scream.snt""GirlScream01"1.0ftrue);
}


 
void Message1(string &in asChildstring &in asParentint alState)
 {
 
SetMessage("Messages""Wiadomosc1"10); 
 }

 
void Message2(string &in asChildstring &in asParentint alState)
 {
 
SetMessage("Messages""Wiadomosc2"10); 
 }

 
void OnEnter()
 {
 
PlayMusic("07_amb"true1.0f4.0f1true);

 } 

Quote:That should do the trick, IF you intended to do it like i do now though.
IF not, we are here to help you out.
---
Here are some things you miswrote;
You were having some {}
Where they should NOT be there.
And:
{// Wrong
AddEntityCollideCallback("Player", "12_girl_scream", "GirlScream", true, 1); //put this in OnSTART
AddEntityCollideCallback("Player", "message1", "Message1", true, 1); //put this in OnSTART
AddEntityCollideCallback("Player", "message2", "Message2", true, 1); //put this in OnSTART
}//Wrong
PlaySoundAtArea("12_girl_scream", "12_girl_scream.snt", "GirlScream01", 0, false); <<<- Use PlaySoundAtEntity in stead.
}
IF you are making a function\script, try with void



RE: Error with scripts - PutraenusAlivius - 01-16-2015

From Julius Caesar's bot, log compiled.

Spoiler below!

ERRORS FOUND: 2
MISTAKES: NO CALLBACK FUNCTION
INCORRECT SYNTAX
FIXING: CORRECT FUNCTION PLACEMENT
CORRECTING SYNTAX

RUN: GENERATE CORRECTION

GENERATING CORRECTION....
WORKING...

PHP Code:
void OnStart()
{
SetSanityDrainDisabled(true);
GiveItemFromFile("lantern""lantern.ent");
for(
int i=0;i25;i++) GiveItemFromFile("tinderbox_"+i"tinderbox.ent");
AddEntityCollideCallback("Player""12_girl_scream""GirlScream"true1);
AddEntityCollideCallback("Player""message1""Message1"true1);
AddEntityCollideCallback("Player""message2""Message2"true1);
}

void GirlScream(string &in asParentstring &in asChildint alState)
{
PlaySoundAtEntity("12_girl_scream""12_girl_scream.snt""GirlScream01"0false);
}

void Message1(string &in asChildstring &in asParentint alState)
{
SetMessage("Messages""Wiadomosc1"10);
}

void Message2(string &in asChildstring &in asParentint alState)
{
SetMessage("Messages""Wiadomosc2"10);
}

void OnEnter()
{
PlayMusic("07_amb"true1.0f4.0f1true);


SUCCESSFUL. CORRECTION GENERATED.

---END---




RE: Error with scripts - DnALANGE - 01-16-2015

??? what went wrong with my script?
didnt check mine tho.
just pointed out things what could have been wrong..