Frictional Games Forum (read-only)
[SCRIPT] Hard to find the errors in the HPS file - 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] Hard to find the errors in the HPS file (/thread-13765.html)

Pages: 1 2


RE: Hard to find the errors in the HPS file - jessehmusic - 03-05-2012

(03-05-2012, 12:47 AM)robinnjensen Wrote: Hello, i have been searching through the script areas and i can't seem to find anything, i'm kinda new to this stuff aswell, but i would be great thankfull if any of you guys would like to help me to fix my script ! Smile

here it is
--------------------------------------------------------------------------------------------------
////////////////////////////
//run when entering map
void OnStart()
{
AddUseItemCallback("", "key_study_1", "Freedom", "KeyOnDoor", true);
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
}




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




void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_brute_2", true);
SetEntityPlayerInteractCallback("cabinetmetal", "Spawn", true);




void Spawn(string &in asEntity)




}
SetEntityActive("corpse_male_1", true);
AddTimer("Scare", 0.5f, "Scare1");




void scare1(string &in asTimer)




GiveSanityDamage(10, true);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);




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




////////////////////////////
// Run when leaving map
void OnLeave()
}
--------------------------------------------------------------------------------------
Really thankfull!


---------------------------
FATAL ERROR
---------------------------
FATAL ERROR: Could not load script file 'custom_stories/Robin's Hell/custom_stories/Robin's Hell/maps/Robin's Hell.hps'!
main (24, 16) : ERR : Expected identifier
main (25, 9) : ERR : Expected identifier
main (29, 1) : ERR : Expected ',' or ';'
main (30, 18) : ERR : Expected identifier
main (35, 1) : ERR : Expected ',' or ';'

---------------------------
OK
---------------------------


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


void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_brute_2", true);
SetEntityPlayerInteractCallback("cabinetmetal", "Spawn", true);

}


{
SetEntityActive("corpse_male_1", true);
AddTimer("Scare", 0.5f, "Scare1");
}

void scare1(string &in asTimer)
{
GiveSanityDamage(10, true);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
}



////////////////////////////
//Run when entering map
void OnEnter()
{
}[align=-webkit-auto]

test that Smile



RE: Hard to find the errors in the HPS file - Adrianis - 03-05-2012

"{

SetEntityActive("corpse_male_1", true);

AddTimer("Scare", 0.5f, "Scare1");

}"

Your missing the function name here, it aint gonna like that Smile

void Spawn(string &in asEntity)
{


SetEntityActive("corpse_male_1", true);


AddTimer("Scare", 0.5f, "Scare1");


}




RE: Hard to find the errors in the HPS file - robinnjensen - 03-05-2012

I'll try them out, i'll tell how it went ! Smile
Here is how i editet my script from you guys,


////////////////////////////
//run when entering map
void OnStart()
{
AddUseItemCallback("", "key_study_1", "Freedom", "KeyOnDoor", true);
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
}

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


void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_brute_2", true);
SetEntityPlayerInteractCallback("cabinetmetal", "Spawn", true);

}



void Spawn(string &in asEntity)
{


SetEntityActive("corpse_male_1", true);


AddTimer("Scare", 0.5f, "Scare1");
}


void scare1(string &in asTimer)
{
GiveSanityDamage(10, true);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
}



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


////////////////////////////
// Run when leaving map
void OnLeave()
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Freedom", false, true);
PlaySoundAtEntity("", "unlock_door", "
Freedom ", 0, false);
RemoveItem("key_study_1");
}


void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_brute_2", true);
SetEntityPlayerInteractCallback("cabinetmetal", "Spawn", true);

}


{
SetEntityActive("corpse_male_1", true);
AddTimer("Scare", 0.5f, "Scare1");
}

void scare1(string &in asTimer)
{
GiveSanityDamage(10, true);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
}



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


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










---------------------------
FATAL ERROR
---------------------------
FATAL ERROR: Could not load script file 'custom_stories/Robin's Hell/custom_stories/Robin's Hell/maps/Robin's Hell.hps'!
 main (54, 1) : ERR  : Expected ',' or ';'




---------------------------
OK   
---------------------------



This is so wierd Sad



RE: Hard to find the errors in the HPS file - Adrianis - 03-06-2012

void OnEnter()
{

Your missing another '}'. Again, look at the line referenced in the error (in this case, line 54) and check over what you've written to make sure its all correct. You know that every function requires void functionname(conditions) followed by { and ended with }, so check over each function making sure they all have these present.

Since this is all posted, and I have to manually count 54 lines down your script, its hard to tell what the problem is. You also appear to have everything in your script doubled up, unless that is just a posting mistake, you need to just have one copy of everything in the script file.

One other thing, you don't need to have the OnEnter() or OnLeave() function in the script to run the map if your not using them. On each of your posts, they have been missing one or other of the required '{' and '}', so I recommend you remove them completely untill you need to use them.

////////////////////////////
//run when entering map
void OnStart()
{
AddUseItemCallback("", "key_study_1", "Freedom", "KeyOnDoor", true);
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
}

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


void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_brute_2", true);
SetEntityPlayerInteractCallback("cabinetmetal", "Spawn", true);
}

void Spawn(string &in asEntity)
{
SetEntityActive("corpse_male_1", true);
AddTimer("Scare", 0.5f, "Scare1");
}

void scare1(string &in asTimer)
{
GiveSanityDamage(10, true);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
}

The above should be everything you need, and should (hopefully!) not produce an error. If it does not error, but does not work, then there may be a problem with your logic and you should rethink how you are using these functions
.

Keep your script writing in the following format,

void functioname(condition)
{
function activity;
}

This easily allows you to see which functions are missing the required syntax aka the '()', the '{}' and the ';' for the parts within the function. You are obviously writing in this way already, but you are not taking advantage of the reasons for writing in this way.

If you do not already, use a program called Notepad++ for your script writing. This does a variety of useful things to help make syntax issues obvious, most useful for you will be the fact that it numbers each line, so when an error like the one above pops up saying there is an issue at line 54, you can go straight to that line and identify the issue far quicker, since you know exactly which line is causing the issue.

Follow this tutorial to get Notepad++ set up correctly for use with HPL scripting.
'
http://www.youtube.com/watch?v=1x3mTmvbSmc'