[1.0.2] Type Conversion - ntoxin66/Dynamic GitHub Wiki
Dynamic supports full type conversion for Bool, Float, Int, String and partial type conversion for Vector and Dynamic.
A members type is based on the type used in the first setter to that member. Once a member has it's type set, the type of that member CAN NOT be changed. If a member is accessed using the wrong type, Dynamic will attempt to convert it's value based on the members actual type.
If two types cant be converted by Dynamic a native error is throw with: "Unsupported member datatype"
Int to Bool
- If the
Intvalue equals0the result isfalse - For all other
Intvalues the result istrue
Float to Bool
- If the
Floatvalue equals0.0the result isfalse - For all other
Floatvalues the result istrue
String to Bool
- If the
Stringvalue equals"false"or"0"the result isfalse - For all other
Stringvalues the result istrue
Bool to Int
- The
Boolvalue is cast to anInt
Float to Int
- The
Floatvalue is rounded to the closest whole number
String to Int
- The
Stringvalue is converted to anIntusing Sourcepawn's stockStringToInt()method
Bool to Float
- The
Boolvalue is converted toFloatusingfloat()
Int to Float
- The
Intvalue is converted toFloatusingfloat()
String to Float
- The
Stringvalue is converted to anFloatusing Sourcepawn's stockStringToFloat()method
Bool to String
- If the
Boolvalue equals true the result will be"True" - If the
Boolvalue equals false the result will be"False"
Int to String
- The
Intvalue is converted toStringusing Sourcepawn's stockIntToString()method
Float to String
- The
Floatvalue is converted toStringusing Sourcepawn's stockFloatToString()method
Next: Dynamic Strings