User Tools

Site Tools


Sidebar

hpl2:tutorials:script:levers_and_secretshelfs

Levers that opens secret shelfs

In this tutorial I (xtron) will show you! (the reader) how to make levers that opens secret bookshelfs!.

The Bookshelf

First off you need to create a moveable bookshelf.

Go to Entities(7) > Gameplay > Look for “shelf_secret_door_rot” and place it where ever you want it. Change it's name to your liking.

secondly you need to create a script area that the shelf will rotate around.

Go to Areas(8) > Select “script” and create an area like so:

img6.imageshack.us/img6/4914/shelf1.png

When you're done adding that area, name it anything for example: rotatearea.

Then press on the bookshelf and go to Entity. The last text box named AngularOffsetArea, you'll need to type in the rotate area you

just created like so:

img155.imageshack.us/img155/948/shelf2.png

Now you're done with the bookshelf!. Let's setup the lever.

Adding the Lever

You will be needing a Lever to make the Bookshelf open so go to

Entities > Gameplay > Look for lever_simple01. You can choose any of those levers. Change the Levers name to your liking.

The lever is now DONE!. Easy ayee?. Let's get working on the script then.

The Script

We will first fix the code that is needed in the void OnStart() area.

void OnStart()
{
SetEntityConnectionStateChangeCallback("lever", "func_shelf");
}

Change “lever” to the name of your Lever you created in the previous part.

Now we need to setup the “move-the-bookshelf-when-lever-is-pressed”

Copy this code and insert it anywhere but void OnStart()

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

Change “shelf” to your shelfs name.

The SetEntityConnectionStateChangeCallback will execute SetMoveObjectState and PlaySoundAtEntity when the levers State turned to 1. The lever's starting position is always 0.

1 = drag down

-1 = drag up

I hope you find this tutorial usefull. Contact on FG forum if you want any specific tutorial or got any questions.

Thanks for reading.

created by xtron

hpl2/tutorials/script/levers_and_secretshelfs.1310607294.txt.gz · Last modified: 2011/07/14 01:34 by xtron