Frictional Games Forum (read-only)
Quick Question - 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: Quick Question (/thread-10487.html)

Pages: 1 2


RE: Quick Question - Kurask - 09-29-2011

Can someone show me how to reduce the LightOff functions into a few lines rather than 60 lines? Here is what I made so far, and it works perfectly fine, I just think it should take less lines to do.


Code:
void TestActive(string &in asParent, string &in asChild, int alState)
{
          SetSwingDoorClosed("castle_1", true, true);
          for (int i=8; i < 23; i++)
          {
                     AddTimer("", i-7, "LightOff"+i);
          }
}

void LightOff8(string &in asTimer)
{
SetLampLit("torch_static01_8", false, true);
}
void LightOff9(string &in asTimer)
{
SetLampLit("torch_static01_9", false, true);
}
void LightOff10(string &in asTimer)
{
SetLampLit("torch_static01_10", false, true);
}
void LightOff11(string &in asTimer)
{
SetLampLit("torch_static01_11", false, true);
}
void LightOff12(string &in asTimer)
{
SetLampLit("torch_static01_12", false, true);
}
void LightOff13(string &in asTimer)
{
SetLampLit("torch_static01_13", false, true);
}
void LightOff14(string &in asTimer)
{
SetLampLit("torch_static01_14", false, true);
}
void LightOff15(string &in asTimer)
{
SetLampLit("torch_static01_15", false, true);
}
void LightOff16(string &in asTimer)
{
SetLampLit("torch_static01_16", false, true);
}
void LightOff17(string &in asTimer)
{
SetLampLit("torch_static01_17", false, true);
}
void LightOff18(string &in asTimer)
{
SetLampLit("torch_static01_18", false, true);
}
void LightOff19(string &in asTimer)
{
SetLampLit("torch_static01_19", false, true);
}
void LightOff20(string &in asTimer)
{
SetLampLit("torch_static01_20", false, true);
}
void LightOff21(string &in asTimer)
{
SetLampLit("torch_static01_21", false, true);
}
void LightOff22(string &in asTimer)
{
SetLampLit("chandelier_large_1", true, true);
}



RE: Quick Question - Tanshaydar - 09-29-2011

Code:
void TestActive(string &in asParent, string &in asChild, int alState)
{
           SetSwingDoorClosed("castle_1", true, true);
           for (int i=8; i < 23; i++)
           {
                      AddTimer("LightOff"+i, i-7, "LightOff");
           }
}

void LightOff( string &in asTimer)
{
    SetLampLit("torch_static01_"+StringSub(asTimer,8,9), false, true);
}



RE: Quick Question - Your Computer - 09-29-2011

(09-29-2011, 12:19 AM)Tanshaydar Wrote:
Code:
void TestActive(string &in asParent, string &in asChild, int alState)
{
           SetSwingDoorClosed("castle_1", true, true);
           for (int i=8; i < 23; i++)
           {
                      AddTimer("LightOff"+i, i-7, "LightOff");
           }
}

void LightOff(string &in asTimer)
{
    SetLampLit("torch_static01_"+StringSub(asTimer,8,9), false, true);
}

It'd be more efficient if you pass the name of the entity into the timer name.

Code:
void TestActive(string &in asParent, string &in asChild, int alState)
{
           SetSwingDoorClosed("castle_1", true, true);
           for (int i=8; i < 23; ++i)
           {
                      AddTimer("torch_static01_"+i, i-7, "LightOff");
           }
}

void LightOff( string &in asTimer)
{
    SetLampLit(asTimer, false, true);
}



RE: Quick Question - Tanshaydar - 09-29-2011

Well, that's all you can get from a quick answer Smile