Frictional Games Forum (read-only)
help with script - 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: help with script (/thread-16792.html)



help with script - mccrazy5 - 07-06-2012

i tried to script something .. tell me please whats wrong with this script... when i start the map the game crash.
void OnStart()
{
AddEntityCollideCallback("Player", "bookarea", "bookscare", true, 1);

}
void bookscare(string &in asParent, string &in asChild, int alState)
{
AddPropForce("book1", 31, 1, -19.25, "world");
SetEntityActive("light1",true);
SetEntityActive("light2",true);
SetEntityActive("mb_window_1",false);
SetEntityActive("mb_window_noglass_1",true);
PlaySoundAtEntity("", "break_glass_large", "mb_window_noglass_1", 0, false);
}


RE: help with script - Cruzore - 07-06-2012

I don't see any problem. Is there a error message when it crashes?


RE: help with script - mccrazy5 - 07-06-2012

yes this is what it says [Image: n4ztbhmwqmnd.png]


RE: help with script - Cruzore - 07-06-2012

the error lies somewhere else. Paste the whole script file of the map "map2.hps"


RE: help with script - mccrazy5 - 07-06-2012

////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "hammer", "block", "breakwood", true);
AddEntityCollideCallback("Player", "bookarea", "bookscare", true, 1);

}

void breakwood (string &in asItem, string &in asEntity)
{
SetEntityActive("block",false);
PlaySoundAtEntity("", "break_wood", "mansion_1", 0, false);
GiveSanityBoost();
RemoveItem(asItem);

void bookscare(string &in asParent, string &in asChild, int alState)
{
AddPropForce("book1", 31, 1, -19.25, "world");
SetEntityActive("light1",true);
SetEntityActive("light2",true);
SetEntityActive("mb_window_1",false);
SetEntityActive("mb_window_noglass_1",true);
SetEntityActive("rain",false);
PlaySoundAtEntity("", "break_glass_large", "mb_window_noglass_1", 0, false);
}


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

}

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


RE: help with script - Adny - 07-06-2012

You had some misplaced brackets, this should be good:


////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "hammer", "block", "breakwood", true);
AddEntityCollideCallback("Player", "bookarea", "bookscare", true, 1);

}

void breakwood(string &in asItem, string &in asEntity)
{
SetEntityActive("block",false);
PlaySoundAtEntity("", "break_wood", "mansion_1", 0, false);
GiveSanityBoost();
RemoveItem(asItem);
}

void bookscare(string &in asParent, string &in asChild, int alState)
{
AddPropForce("book1", 31, 1, -19.25, "world");
SetEntityActive("light1",true);
SetEntityActive("light2",true);
SetEntityActive("mb_window_1",false);
SetEntityActive("mb_window_noglass_1",true);
SetEntityActive("rain",false);
PlaySoundAtEntity("", "break_glass_large", "mb_window_noglass_1", 0, false);
}


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

}

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


RE: help with script - Cruzore - 07-06-2012

void breakwood (string &in asItem, string &in asEntity)
{
SetEntityActive("block", false);
PlaySoundAtEntity("", "break_wood", "mansion_1", 0, false);
GiveSanityBoost();
RemoveItem(asItem);

void bookscare(string &in asParent, string &in asChild, int alState)
the function "breakwood" has no closing bracket }


RE: help with script - mccrazy5 - 07-06-2012

thank you , that works now