void CFlowTrackEventNode::OnTrackEvent(IAnimSequence *pSequence, int reason, const char* event, void* pUserData)
{
	if (reason != ITrackEventListener::eTrackEventReason_Triggered)
		return;

	// Find output port and call it
	for (int i = 0; i < m_nOutputs; ++i)
	{
		if (m_outputs[i].name && strcmp(m_outputs[i].name, event) == 0)
		{
			// Call it
			TFlowInputData value;
			const char* param = (const char*)pUserData;
			value.Set(string(param));
			ActivateOutput(&m_actInfo, i, value);
			return;
		}
	}
}
int CScriptBind_GameToken::SetToken( IFunctionHandler *pH)
{
	SCRIPT_CHECK_PARAMETERS(2);
	const char* tokenName = 0;
	if (pH->GetParams(tokenName) == false)
	{
		GameWarning("[GameToken.SetToken] Usage: GameToken.SetToken TokenName TokenValue]");
		return pH->EndFunction();
	}
	ScriptAnyValue val;
	TFlowInputData data;

	if (pH->GetParamAny( 2, val) == false)
	{
		GameWarning("[GameToken.SetToken(%s)] Usage: GameToken.SetToken TokenName TokenValue]", tokenName);
		return pH->EndFunction();
	}
	switch (val.type)
	{
	case ANY_TBOOLEAN:
		{ 
			bool v; 
			val.CopyTo(v); 	
			data.Set(v);
		}
		break;
	case ANY_TNUMBER:
		{ 
			float v; 
			val.CopyTo(v); 		
			data.Set(v);
		}
		break;
	case ANY_TSTRING:
		{ 
			const char* v;
			val.CopyTo(v); 		
			data.Set(string(v));
		}
		break;
	case ANY_TVECTOR:
		{ 
			Vec3 v; 
			val.CopyTo(v); 		
			data.Set(v);
		}
	case ANY_TTABLE:
		{
			float x,y,z;
			IScriptTable * pTable = val.table;
			assert (pTable != 0);
			if (pTable->GetValue( "x", x ) && pTable->GetValue( "y", y ) && pTable->GetValue( "z", z ))
			{
				data.Set(Vec3(x,y,z));
			}
			else
			{
				GameWarning("[GameToken.SetToken(%s)] Cannot convert parameter type '%s' to Vec3", tokenName, ScriptAnyTypeToString(val.type));
				return pH->EndFunction();
			}
		}
		break;
	case ANY_THANDLE:
		{
			ScriptHandle handle;
			val.CopyTo(handle);
			data.Set((EntityId)handle.n);
		}
		break;
	default:
		GameWarning("[GameToken.SetToken(%s)] Cannot convert parameter type '%s'", tokenName, ScriptAnyTypeToString(val.type));
		return pH->EndFunction();
		break; // dummy ;-)
	}
#ifdef SCRIPT_GAMETOKEN_ALWAYS_CREATE
	m_pTokenSystem->SetOrCreateToken(tokenName, data);
#else
	IGameToken *pToken = m_pTokenSystem->FindToken(tokenName);
	if (!pToken)
		GameWarning("[GameToken.SetToken] Cannot find token '%s'", tokenName);
	else
	{
		pToken->SetValue(data);
	}
#endif
	return pH->EndFunction();
}