[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
Int
value equals0
the result isfalse
- For all other
Int
values the result istrue
Float
to Bool
- If the
Float
value equals0.0
the result isfalse
- For all other
Float
values the result istrue
String
to Bool
- If the
String
value equals"false"
or"0"
the result isfalse
- For all other
String
values the result istrue
Bool
to Int
- The
Bool
value is cast to anInt
Float
to Int
- The
Float
value is rounded to the closest whole number
String
to Int
- The
String
value is converted to anInt
using Sourcepawn's stockStringToInt()
method
Bool
to Float
- The
Bool
value is converted toFloat
usingfloat()
Int
to Float
- The
Int
value is converted toFloat
usingfloat()
String
to Float
- The
String
value is converted to anFloat
using Sourcepawn's stockStringToFloat()
method
Bool
to String
- If the
Bool
value equals true the result will be"True"
- If the
Bool
value equals false the result will be"False"
Int
to String
- The
Int
value is converted toString
using Sourcepawn's stockIntToString()
method
Float
to String
- The
Float
value is converted toString
using Sourcepawn's stockFloatToString()
method
Next: Dynamic Strings