Frictional Games Forum (read-only)
[SCRIPT] if 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] if script (/thread-14407.html)



if script - GoranGaming - 04-01-2012

I need a script like:

if(EntityIsActive){
//Do Stuff
}

Can you do that?


RE: if script - Apjjm - 04-01-2012

Create a script area at the origin of the map (0,0,0). Scale it to be really by (E.g 500,500,500 scale) so that the entire level is covered by the script area. Call it something like "script_area_world".


Code:
//Change this if you call your script area something different
const string WORLD_AREA = "script_area_world"

/* This function will return true if the given (colliding) entity exists & is active.
    asEntity may use * and "Player". */
bool GetEntityActive(string &in asEntity)
 {
   return GetEntitiesCollide(asEntity,WORLD_AREA);
 }

usage would then be something like:
Code:
void test()
{
   if(GetEntityActive("barrel01_1"))
    AddDebugMessage("Barrel 1 is active!",false);
}