Frictional Games Forum (read-only)
Help with combining 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: Help with combining scripts (/thread-21589.html)



Help with combining scripts - Wank - 05-24-2013

I can't put these together and get them to work. First script-

void OnStart()
{
AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
}

void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Enemy1", true);
AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");
}

Second script-

void OnStart()
{
AddUseItemCallback("", "key_study_one", "mansion_3", "unlock", true);
}

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


RE: Help with combining scripts - Tomato Cat - 05-24-2013

Are you getting any sort error?


RE: Help with combining scripts - PutraenusAlivius - 05-24-2013

Did you get any errors? In case you do, I put the whole thing in one script.
Spoiler below!

void OnStart()

{

AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
AddUseItemCallback("", "key_study_one", "mansion_3", "unlock", true);

}



void SpawnEnemy1(string &in asParent, string &in asChild, int alState)

{

SetEntityActive("Enemy1", true);

AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");

AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");

AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");

AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");

AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");

AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");

}


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

{

SetSwingDoorLocked("door", false, true);

PlaySoundAtEntity("", "unlock_door", "door", 0, false);

RemoveItem("item");

}




RE: Help with combining scripts - Wank - 05-24-2013

(05-24-2013, 01:34 AM)Tomato Cat Wrote: Are you getting any sort error?

Huh, I was, now i'm not. Even though I am not getting an error, it still doesn't work.

(05-24-2013, 02:00 AM)JustAnotherPlayer Wrote: Did you get any errors? In case you do, I put the whole thing in one script.
Spoiler below!

void OnStart()

{

AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
AddUseItemCallback("", "key_study_one", "mansion_3", "unlock", true);

}



void SpawnEnemy1(string &in asParent, string &in asChild, int alState)

{

SetEntityActive("Enemy1", true);

AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");

AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");

AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");

AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");

AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");

AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");

}


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

{

SetSwingDoorLocked("door", false, true);

PlaySoundAtEntity("", "unlock_door", "door", 0, false);

RemoveItem("item");

}


Huh, I was, now i'm not. Even though I am not getting an error, it still doesn't work.


RE: Help with combining scripts - Tomato Cat - 05-24-2013

JustAnotherPlayer made some adjustments for you:

PHP Code:
PlaySoundAtEntity("""unlock_door""door"0false);
//This is proper. "Quotations" denote a string argument. JAP fixed this for you.

//You had this:

PlaySoundAtEntity("""unlock_door"door0false);
//"door" is not a string. It was also like this in the SetSwing door function. 

Also, right here:

PHP Code:
RemoveItem("item");
//If you're trying to use the asItem parameter to remove said item, it would be asItem rather than "item"
RemoveItem(asItem); //This is correct 

I'm *guessing* this is what's wrong. I dunno. What specifically is happening?

Make sure your level editor names match etcetc.


RE: Help with combining scripts - Wank - 05-24-2013

(05-24-2013, 01:34 AM)Tomato Cat Wrote: Are you getting any sort error?

I am getting an error that says "FATAL ERROR (16, 20) :Expected identifier

void OnStart()
{
AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
}

void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Enemy1", true);
AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");
}
AddUseItemCallback("", "key_study_one", "mansion_3", "UseKeyOnDoor" , true);

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "door", 0, false);
RemoveItem(asItem);;
}
void OnLeave ()
{
}


RE: Help with combining scripts - PutraenusAlivius - 05-24-2013

Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
AddUseItemCallback("", "key_study_one", "mansion_3", "UseKeyOnDoor", true);
}

void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Enemy1", true);
AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");
}

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




RE: Help with combining scripts - Wank - 05-24-2013

(05-24-2013, 12:44 PM)JustAnotherPlayer Wrote:
Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
AddUseItemCallback("", "key_study_one", "mansion_3", "UseKeyOnDoor", true);
}

void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Enemy1", true);
AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");
}

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


Thank you, this worked!


RE: Help with combining scripts - Wooderson - 05-24-2013

What a nice name xD