Frictional Games Forum (read-only)
Amnesia Error, need 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: Amnesia Error, need help. (/thread-15675.html)



Amnesia Error, need help. - Wapez - 05-28-2012

Hey guys, so i've been working alot on my custom story, and now i'm really tired, it kinda makes me retarded. So please tell me why Amnesia crashes, I'm sure it's some lame stupid problem, i'm just feeling really retarded right now. Please help.


These are the Callbacks for my padlock, that i'm supposed to break with a "stone_hammer_chipper".



AddUseItemCallback("", "stone_hammer_chipper", "padlock_rusty_1", "UsedKeyOnDoor2", true);
AddUseItemCallback("", "stone_hammer_chipper", "prison_section_1", "UsedKeyOnDoor2", true);
AddUseItemCallback("", "chipper_1", "prison_section_1", "UsedKeyOnDoor2", false);
AddUseItemCallback("", "chipper_1", "padlock_rusty_1", "UsedKeyOnDoor2", false);
AddUseItemCallback("", "hammer_2", "prison_section_1", "UsedKeyOnDoor2", false);
AddUseItemCallback("", "hammer_2", "padlock_rusty_1", "UsedKeyOnDoor2", false);
SetEntityPlayerInteractCallback("prison_section_1", "PadLockHint", true);
SetEntityPlayerInteractCallback("padlock_rusty_1", "PadLockHint", true);

This is the Callback syntax.


void UsedKeyOnDoor2(string &in item, string &in entity)
{
if(asItem == "hammer_2")
SetMessage("Padlock", "UseHammerOnPadlock", 0);
if(asItem == "chipper_1")
SetMessage("Padlock", "UseChipperOnPadlock", 0);

if(asItem == "stone_hammer_chipper")
SetPropHealth("padlock_rusty_1", 0.0f);
SetEntityActive("padlock_broken_1", true);
SetEntityActive("padlock_rusty_1", false);
RemoveItem("stone_hammer_chipper");
PlaySoundAtEntity("", "impact_metal_high.snt", "prison_section_1", 0, false);
GiveSanityBoost();
CompleteQuest("padlockquest", "PadLockQuest");
SetEntityPlayerInteractCallback("prison_section_1", "", false);
PlayMusic("12_puzzle_cavein.ogg", false, 1.0, 0, 1, true);
AddTimer("", 30.0, "ResetMusic"); //Reset the music
}

I think it said it was 4 errors when the game crashed. Something with that a "boolean" (or something like that) value was needed, 1 said that the "asItem" wasn't declared, and the others said something else.

Thank you for taking your time!



RE: Amnesia Error, need help. - Putmalk - 05-28-2012

Need to see entire script and every error that is being generated.

Please do not use red text, that is an eyesore to read.

Code:
if(asItem == "stone_hammer_chipper")

SetPropHealth("padlock_rusty_1", 0.0f);

SetEntityActive("padlock_broken_1", true);

SetEntityActive("padlock_rusty_1", false);

RemoveItem("stone_hammer_chipper");

PlaySoundAtEntity("", "impact_metal_high.snt", "prison_section_1", 0, false);

GiveSanityBoost();

CompleteQuest("padlockquest", "PadLockQuest");

SetEntityPlayerInteractCallback("prison_section_1", "", false);

PlayMusic("12_puzzle_cavein.ogg", false, 1.0, 0, 1, true);

AddTimer("", 30.0, "ResetMusic"); //Reset the music

I see an issue right here. When using the if statement, if you don't add brackets, it only reads the next line as part of the if statement. So you need to this entire block with

Code:
if(asItem == "stone_hammer_chipper")
{

SetPropHealth("padlock_rusty_1", 0.0f);

SetEntityActive("padlock_broken_1", true);

SetEntityActive("padlock_rusty_1", false);

RemoveItem("stone_hammer_chipper");

PlaySoundAtEntity("", "impact_metal_high.snt", "prison_section_1", 0, false);

GiveSanityBoost();

CompleteQuest("padlockquest", "PadLockQuest");

SetEntityPlayerInteractCallback("prison_section_1", "", false);

PlayMusic("12_puzzle_cavein.ogg", false, 1.0, 0, 1, true);

AddTimer("", 30.0, "ResetMusic"); //Reset the music
}

Although I would prefer the much easier to read:

Code:
if(asItem != "stone_hammer_chipper") return; //we didn't use the stone hammer/chipper, so do nothing.



SetPropHealth("padlock_rusty_1", 0.0f);

SetEntityActive("padlock_broken_1", true);

SetEntityActive("padlock_rusty_1", false);

RemoveItem("stone_hammer_chipper");

PlaySoundAtEntity("", "impact_metal_high.snt", "prison_section_1", 0, false);

GiveSanityBoost();

CompleteQuest("padlockquest", "PadLockQuest");

SetEntityPlayerInteractCallback("prison_section_1", "", false);

PlayMusic("12_puzzle_cavein.ogg", false, 1.0, 0, 1, true);

AddTimer("", 30.0, "ResetMusic"); //Reset the music


void UsedKeyOnDoor2(string &in item, string &in entity) should also be:

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