Frictional Games Forum (read-only)
Need Help for Scripting Rotating Bookshelf - 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: Need Help for Scripting Rotating Bookshelf (/thread-17999.html)



Need Help for Scripting Rotating Bookshelf - zTizzle - 08-28-2012

Im trying to script my custom map so that when you pull a lever it rotates a bookshelf so the player can advance, but it isnt working.
Here is my code:
PHP Code:
    SetEntityConnectionStateChangeCallback("lever_book""shelf");
void shelf(string &in asEntityint alState){     if (alState == 1)     {     SetMoveObjectState("books",1.0f);     PlaySoundAtEntity("""quest_completed.snt""shelf_move_1"0false);          return;     }} 

books is the name of the bookshelf, and lever_book is the name of the lever. Any ideas?

sorry the code looks really bad, this is my first post on this forum,


RE: Need Help for Scripting Rotating Bookshelf - Adny - 08-28-2012

Can you please specify what isn't working? Does it not have the desired effect in game, or is it crashing and giving you a message of what is causing it?


RE: Need Help for Scripting Rotating Bookshelf - johnbox - 08-28-2012

(08-28-2012, 03:12 AM)zTizzle Wrote: Im trying to script my custom map so that when you pull a lever it rotates a bookshelf so the player can advance, but it isnt working.
Here is my code:
Spoiler below!
PHP Code:
    SetEntityConnectionStateChangeCallback("lever_book""shelf");
void shelf(string &in asEntityint alState){     if (alState == 1)     {     SetMoveObjectState("books",1.0f);     PlaySoundAtEntity("""quest_completed.snt""shelf_move_1"0false);          return;     }} 

books is the name of the bookshelf, and lever_book is the name of the lever. Any ideas?

sorry the code looks really bad, this is my first post on this forum,
first, congratulations, i have no idea how, but you managed to confuse my android browser completely with this script. i'm not sure, if i'm the only one with this problem, but maybe you cut put the code into a spoiler, so this thread isn't messed up the whole time.
(you can do spoiler with [spoi ler] your text [/spoi ler] (obviously without the spaces^^)

but ok, first, i would recommend to make use of the lovely enter-key, makes it easier to work with, and sometimes, for example in python, you have to do it. if it's just because of the mixed up forum-post, then... this doens't matter, excuse me.

and could you tell us, what specifically is wrong? what happens in the cs, does the switch simply not work? crashing?


edit: and andy was faster, as always. sorry for the doubled question.


RE: Need Help for Scripting Rotating Bookshelf - Adny - 08-28-2012

Here's how your script should look:


void OnStart()
{
SetEntityConnectionStateChangeCallback("lever_book", "shelf");
}


void shelf(string &in asEntity, int alState)
{
if(alState == 1)
{
SetMoveObjectState("books", 1.0f);
PlaySoundAtEntity("", "quest_completed.snt", "Player", 0, false);
}
}

And here's a quick tutorial for secret shelves (just follow the top portion labeled "The Bookshelf"):

http://wiki.frictionalgames.com/hpl2/tutorials/script/levers_and_secretshelfs


Hope that helped.