Frictional Games Forum (read-only)
[SCRIPT] Wheel Troubles! - 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 Troubles! (/thread-23586.html)



Wheel Troubles! - BonesTheRabbit - 10-13-2013

I've been trying to get this working, and I'm guessing I'm doing something silly, because it just doesn't want to work with me. The idea is that a function should trigger when the valve is turned all the way to its endpoint. The names are all just for the sake of clarity, and the functions in the trigger are just for testing.

Code:
void OnEnter()
{    
    SetEntityConnectionStateChangeCallback("EntityName", "FunctionName");
}

void FunctionName(string &in asEntity, int ValveState)
{    
    if (ValveState == 1)
    {
        SetPropObjectStuckState("EntityName", 1);
        PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.0f, false);
    }
}

I've triple checked the entity name, but the valve isn't locking, and the sound isn't playing. I've been looking through various tutorials, though most deal with levers, and I'm really stumped. I have a valve which opens a sliding door elsewhere on my map, and that works fine, but this one is proving problematic.

Any help would be greatly appreciated.


RE: Wheel Troubles! - DnALANGE - 10-14-2013

void YOURCODENAMEINEDITOR(string &in asEntity, int alState)
{
if (alState == 1)
{
SetPropObjectStuckState("EntityName", 1);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.0f, false);
}
}


***YOURCODENAMEINEDITOR =
Open editor -> go to your wheel -> EntityTAB -> ConnectStateChangeCallBack "YOURCODENAMEINEDITOR"

You can remove this line then :
SetEntityConnectionStateChangeCallback("EntityName", "FunctionName");


RE: Wheel Troubles! - Apjjm - 10-14-2013

Stick an AddDebugMessage() in the callback before the if statement - so you can check if it is being called and what the state of the lever is:
Code:
void FunctionName(string &in asEntity, int ValveState)
{    
    AddDebugMessage(asEntity + " - state: " + ValveState,false);
    if (ValveState == 1)
    {
        SetPropObjectStuckState("EntityName", 1);
        PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.0f, false);
    }
}
This would let you determine if the problem is in setting up the callback or if the entity is some strange valve/wheel that turns from max->min instead of min->max.


RE: Wheel Troubles! - BonesTheRabbit - 10-15-2013

Got it working. Not sure what was wrong originally, but once I added the debug message, the thing started working. Thanks for the help!