Frictional Games Forum (read-only)
[SCRIPT] Broken 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: [SCRIPT] Broken Script (/thread-15104.html)



Broken Script - Manbearpig116 - 04-26-2012

I have two scripts that don't seem to be working right.

The first is trying to make a grunt spawn when walking into a specific area but when I run the map it doesn't work
This the script in full

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Monsterdoorkey", "Monsterdoor", "UsedKeyOnDoor", true);
}

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

void OnLeave()

////////////////////////////
// Run when leaving map



{
AddEntityCollideCallback("Player", "PlayerCollide", "SpawnMonster", true, 1);
}
void SpawnMonster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_3", true);

}

I'm also trying to make a key unlock a door on another map but when I try to unlock the door it says "cannot use item this way"
Here is the script in full

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "RoomTwoArea", "CollideRoomTwo", true, 1);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alstate)
{
SetSwingDoorClosed("RoomTwoDoor", true, true);
GiveSanityDamage(90 , true);
PlayGuiSound("react_past", 1);
}

void OnEnter()
{
AddUseItemCallback("", "WaterDoorkey", "WaterDoor", "UsedKeyOnDoor", true);
}

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

If anyone can offer a solution, I would be glad to hear it.



RE: Broken Script - SilentStriker - 04-26-2012

wow your script is a chaos ^^



Let me rewrite it for you:

First Map:


Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "Monsterdoorkey", "Monsterdoor", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player", "PlayerCollide", "SpawnMonster", true, 0);
}

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

void SpawnMonster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_3", true);
}

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

}

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

}

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "RoomTwoArea", "CollideRoomTwo", true, 0);
AddUseItemCallback("", "WaterDoorkey", "WaterDoor", "UsedKeyOnDoor", true);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alstate)
{
SetSwingDoorClosed("RoomTwoDoor", true, true);
GiveSanityDamage(90 , true);
PlayGuiSound("react_past", 1);
}

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

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

}

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

}

Check so everything is spelled right Smile