Frictional Games Forum (read-only)
[SCRIPT] Wheel lever wont stick in positon once turned - 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] Wheel lever wont stick in positon once turned (/thread-50274.html)



Wheel lever wont stick in positon once turned - serbusfish - 06-24-2016

I have wrote a script which opens a bulkhead door, but for some reason the wheel lever wont stick in position even though it is sucessfully opening the door. I tried using the stuckstate command and SetPropStaticPhysics but neither work. Here is what I have:

Quote:void OnStart()
{
SetEntityConnectionStateChangeCallback("Gate_Valve_1", "ValveEventHandler");

void ValveEventHandler (string &in asEntity, int alState)

{
if (alState == 1)
{
SetPropStaticPhysics("Gate_Valve_1", true);
SetMoveObjectStateExt("sewer_bulkhead_1", 0.88, 5, 1, 0.12, true);

}
}

Any help is really appreciated.


RE: Wheel lever wont stick in positon once turned - Mudbill - 06-24-2016

The script is incorrectly formatted so I assume you're crashing the game?

Remember you cannot call a void block function from within another function (like inside your OnStart). Try this:

PHP Code:
void OnStart()
{
    
SetEntityConnectionStateChangeCallback("Gate_Valve_1""ValveEventHandler");
}

void ValveEventHandler(string &in asEntityint alState)
{
    if(
alState == 1)
    {
        
SetPropStaticPhysics("Gate_Valve_1"true);
        
SetMoveObjectStateExt("sewer_bulkhead_1"0.88510.12true);
    }


With this you can also try //commenting out the SetPropStaticPhysics and see if SetWheelStuckState works better for you if you want.


RE: Wheel lever wont stick in positon once turned - serbusfish - 06-25-2016

(06-24-2016, 05:08 PM)Mudbill Wrote: The script is incorrectly formatted so I assume you're crashing the game?

Remember you cannot call a void block function from within another function (like inside your OnStart). Try this:

I added the {} to the OnStart part manually so that is why it look wrong, the actual script file is correct and the level works fine but the wheel wont become stuck or static.

EDIT: Well this is strange because now the script is working!

I have had this sort of thing happen before, for example a few times now I have put a custom sound in my CS folder and the game wont find it, but the next day after a PC restart it now does find it. Something to do with cache perhaps? I dont know, but my script now works so thank you anyway Smile


RE: Wheel lever wont stick in positon once turned - Mudbill - 06-25-2016

You can try replacing the name of the wheel with asEntity inside your ValveEventHandler function. That will make sure it always gets the right name of the entity.

PHP Code:
SetPropStaticPhysics(asEntitytrue); 

Which entity as you using btw?


RE: Wheel lever wont stick in positon once turned - serbusfish - 06-25-2016

(06-25-2016, 08:02 AM)Mudbill Wrote: You can try replacing the name of the wheel with asEntity inside your ValveEventHandler function. That will make sure it always gets the right name of the entity.

PHP Code:
SetPropStaticPhysics(asEntitytrue); 

Which entity as you using btw?

Cheers for that tip, I am using 'valve_iron'.