Frictional Games Forum (read-only)
Expcected Error help! - 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: Expcected Error help! (/thread-24619.html)



Expcected Error help! - FoodOnCrack - 02-14-2014

Hi there, I have made my first custom story, the map is working fine. I have a line of commands for a key and door which worked at first, now i have added a jumpscare which i have seen in a tutorial on youtube. It crashes immediatly and says: main 14,19 EXPECTED IDENTIFIER. I can also give a screenshot of the code in notepad ++, private message me.

My codes are:
PHP Code:
void OnStart()
{
    
AddEntityCollideCallback("Player""Teleport_Script_1""jumpscare"true1);
}

void jumpscare(string &in asParentstring &in asChildint alStates)

{
    
SetEntityActive("corpse_male_3"true);
    
AddPropForce("corpse_male_3"00100"world");
}


AddUseItemCallback(" ""key_tower_1""castle_1""KeyOnDoor"true); 

void KeyOnDoor(string &in asItemstring &in asEntity)

{
SetSwingDoorLocked("castle_1"falsetrue);
PlaySoundAtEntity("""unlock_door""castle_1"0false);
RemoveItem("key_tower_1");


void OnStart()
{
AddEntityCollideCallback("Player""Teleport_Script_1""jumpscare"true1);
}

void jumpscare(string &in asParentstring &in asChildint alStates)

{
    
SetEntityActive("corpse_male_3"true);
    
AddPropForce("corpse_male_3"00100"world");


Is there anyone who understands the scripting better than me and can help me out? Thank you!!!


RE: Expcected Error help! - Mudbill - 02-14-2014

First off, you can only have 1 script block with the same name (for example OnStart). Having multiple will cause a crash. If you need more script inside your OnStart block, just add it all inside the same one.

For example:
Code:
void OnStart()
{
    code1();
    code2();
}

Secondly, you can not have a callback script outside a block. This line:

Code:
AddUseItemCallback(" ", "key_tower_1", "castle_1", "KeyOnDoor", true);

is located between 2 blocks, therefore causing a crash as well. You want to move this within your OnStart block.

Try that and tell me how it goes. I'll assist further if you need more help (that is, if I can cause I'm about to go to bed. If I can't, there are many others here).


RE: Expcected Error help! - FoodOnCrack - 02-23-2014

(02-14-2014, 01:14 AM)Mudbill Wrote: First off, you can only have 1 script block with the same name (for example OnStart). Having multiple will cause a crash. If you need more script inside your OnStart block, just add it all inside the same one.

For example:
Code:
void OnStart()
{
    code1();
    code2();
}

Secondly, you can not have a callback script outside a block. This line:

Code:
AddUseItemCallback(" ", "key_tower_1", "castle_1", "KeyOnDoor", true);

is located between 2 blocks, therefore causing a crash as well. You want to move this within your OnStart block.

Try that and tell me how it goes. I'll assist further if you need more help (that is, if I can cause I'm about to go to bed. If I can't, there are many others here).



Thanks a lot! I have learned way more from scripting since i started a few weeks ago. I also use Geany now instead of Notepad++. A guy on youtube called ThisIsYourComputer has a good tutorial on how to set up geany for amnesia scripting.


RE: Expcected Error help! - Daemian - 02-24-2014

ThisIsYourComputer xD
Yeap, it's YourComputer, he's been off since 10-31-2013 (last visit)
I wonder what happened to him?


RE: Expcected Error help! - Romulator - 02-24-2014

31/10/2013 was halloween... :o


RE: Expcected Error help! - Mudbill - 02-24-2014

I'm not saying it was aliens, but... Aliens.


RE: Expcected Error help! - davide32 - 02-24-2014

Look at what you type:
void OnStart()
{
AddEntityCollideCallback("Player", "Teleport_Script_1", "jumpscare", true, 1);
}

void jumpscare(string &in asParent, string &in asChild, int alStates)

{
SetEntityActive("corpse_male_3", true);
AddPropForce("corpse_male_3", 0, 0, 100, "world");
}


AddUseItemCallback(" ", "key_tower_1", "castle_1", "KeyOnDoor", true);

void KeyOnDoor(string &in asItem, string &in asEntity)

{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("key_tower_1");
}

but it might be:
void OnStart()
{
AddEntityCollideCallback("Player", "Teleport_Script_1", "jumpscare", true, 1);
}
void jumpscare(string &in asParent, string &in asChild, int alState)

{
SetEntityActive("corpse_male_3", true);
AddPropForce("corpse_male_3", 0, 0, 100, "world");
}
Errors: 2 voids OnStart()
else:
void jumpscares(string &in asParent, string &in asChild, int alState)