Frictional Games Forum (read-only)
How do i Move a Shelf with a 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: How do i Move a Shelf with a script? (/thread-5746.html)



How do i Move a Shelf with a script? - machosalad - 12-15-2010

i am trying to make a script that moves a tall shelf to reveal a secret passage. The entity of the shelf is "shelf_high01.ent" and the name of it is "SecretShelf1".

This is the script that runs:

Code:
void RevealSecretPassage(string &in asParent, string &in asChild, int alState)
{
    PlayMusic("Secret1.ogg", false, 1.0f, 0, 0, true);
    FadeLightTo("SecretPointLight1", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f);
    SetMoveObjectState("SecretShelf1", 1);
    CreateParticleSystemAtEntity("dust", "ps_dust_falling_door_quick", "SecretShelf1", false);
    PlaySoundAtEntity("", "scrape_rock", "SecretShelf1", 0, false);
    GiveSanityBoostSmall();
}

But the shelf never moves! The music plays, so i'm sure the function runs.
What am i doing wrong?


RE: How do i Move a Shelf with a script? - Oscar House - 12-15-2010

Have you considered making two of those shelves, and when the function is called, it deactivates the closed shelf and activates the open shelf?
Something like

Code:
void RevealSecretPassage(string &in asParent, string &in asChild, int alState)
{
    PlayMusic("Secret1.ogg", false, 1.0f, 0, 0, true);
    FadeLightTo("SecretPointLight1", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f);
    SetEntityActive("SecretShelf1", false);
    SetEntityActive("SecretShelf2", true);
    CreateParticleSystemAtEntity("dust", "ps_dust_falling_door_quick", "SecretShelf1", false);
    PlaySoundAtEntity("", "scrape_rock", "SecretShelf1", 0, false);
    GiveSanityBoostSmall();
}

Unless you're supposed to see the shelf when it opens, for that I don't know the answer. Maybe it's supposed to be
SetMoveObjectState("SecretShelf1", true); ?


RE: How do i Move a Shelf with a script? - Andross - 12-22-2010

You can't move random entities with the SetMoveObjectState() function; it only works on items specifically made to move in a certain way. In the Archives level, they use "shelf_secret_door.ent" to implement a secret passage behind a shelf.