Frictional Games Forum (read-only)
[SCRIPT] Moving shelf via button - 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] Moving shelf via button (/thread-12741.html)



Moving shelf via button - Quotentote - 01-21-2012

i created an area (on the button) where the player has to interact with (like pushing this button)

PHP Code:
void OnStart()
{
AddEntityCollideCallback("Player""shelfarea""rotate"true1);
}

void rotate(string &in asEntityint alState)
    {
         
SetMoveObjectState("rotate_shelf_01",1.0f);
         
PlayMusic("10_puzzle01.ogg",false,0.7,0.1,10,false);
         
GiveSanityBoostSmall();
         return;
    } 

why does it not work Sad

(yes i connected the shelf with the angular offset area//all names are correct etc)

greetings



RE: Moving shelf via button - Tripication - 01-21-2012

via button? why u use Collision Callback then?

use this

void OnStart()
{
SetEntityConnectionStateChangeCallback("BUTTONNAMEHERE", "func_shelf");

}


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


Editing the footage i got from the livestream btw XD



________________________________________________
Apparently this doesn't work ^^, so im stumped for answers. Statyk, russ, flames, anyone?

Unless its the no spaces after the commas...

Just figured it out, wrong syntax

void rotate(string &in asParent, string &in asChild, int alState)


RE: Moving shelf via button - flamez3 - 01-21-2012

Go into the level editor, click on the button. In the entity tab. Under PlayerInteractCallBack. Type ShelfMove

Hit enter and save. In your .hps put this in:

Quote:void ShelfMove(string &in asEntity)
{
SetMoveObjectState("Shelf_name",1.0f);
PlaySoundAtEntity("", "quest_completed.snt", "shelf_move_1", 0, false);
return;
}



RE: Moving shelf via button - triadtimes - 01-21-2012

Okay, you ready for this? I'm gonna give y'all the low down on how buttons work in Amnesia. Let's gooo...


Go into your level editor and select the button you want to be press-able. From there go to Entities and go down to the box that says PlayerInteractCallback (d'ya see it?). Okay, type whatever you want into this box (let's say PressButton in this case). Now go and take your already developed script and make it look a little like this:

Spoiler below!
OnStart
{
//Functions go here //But we don't need one for this button
}

//Lines of code

void PressButton(string &in asEntity) //Entirely new callback
{
//Stuff you wanted to do when the button is pressed
}

That's right, we don't need to have something in the OnStart for this, it's all LevelEditor & callback, baby.

Okay, hope that helped. See ya.


RE: Moving shelf via button - Quotentote - 01-21-2012

thanks dude, it finally works.
goddamn it was easier as i thought Big Grin