Talk:IO type variant
Jump to navigation
Jump to search
Uh, what does param=variant mean?
— SirYodaJedi (talk) 18:47, 5 May 2025 (PDT)
- It means the parameter is passed to the input without converting it first.
- from logicentities.cpp where logic_case is + comments
... DEFINE_INPUTFUNC(FIELD_INPUT, "InValue", InputValue) ... COutputVariant m_OnDefault; ... void CLogicCase::InputValue( inputdata_t &inputdata ) { const char *pszValue = inputdata.value.String(); //the value gets converted here to string, if InValue was of type FIELD_STRING it wouldn't be able to take anything beside string or ehandle as those conversions aren't implemented, see warning on material_modify_control's page near SetMaterialVar input for (int i = 0; i < MAX_LOGIC_CASES; i++) { if ((m_nCase[i] != NULL_STRING) && !stricmp(STRING(m_nCase[i]), pszValue)) { m_OnCase[i].FireOutput( inputdata.pActivator, this ); return; } } m_OnDefault.Set( inputdata.value, inputdata.pActivator, this ); //m_OnDefault is also variant so it passes the same type as was received out }
- So for example lets say InValue input is called from output of type float. It gets the float without change, inside it converts to string then compares that to its cases and if there is no match then OnDefault is fired also with type variant with the same float that was received and can be accepted only by other variant type inputs.
- These should be all the output types types + COutputEvent which means nothing being passed
- --Nescius (talk) 23:37, 5 May 2025 (PDT)
// useful typedefs for allowed output data types typedef CEntityOutputTemplate<variant_t,FIELD_INPUT> COutputVariant; //seems that only logic_case has this typedef CEntityOutputTemplate<int,FIELD_INTEGER> COutputInt; typedef CEntityOutputTemplate<float,FIELD_FLOAT> COutputFloat; typedef CEntityOutputTemplate<string_t,FIELD_STRING> COutputString; typedef CEntityOutputTemplate<EHANDLE,FIELD_EHANDLE> COutputEHANDLE; typedef CEntityOutputTemplate<Vector,FIELD_VECTOR> COutputVector; typedef CEntityOutputTemplate<Vector,FIELD_POSITION_VECTOR> COutputPositionVector; //doesn't seem used anywhere typedef CEntityOutputTemplate<color32,FIELD_COLOR32> COutputColor32;