On this page
type
Runtime type inspection.
Syntax
Atlas Script
typeReturn value
See the remarks for the returned value and runtime behavior.
Type-name constants
Every constant the native script registry defines for type, generated from the registry manifest.
| Constant | type() result |
|---|---|
type.array | array |
type.bool | bool |
type.float | float |
type.font | font |
type.handle | handle |
type.int32 | int32 |
type.model | model |
type.null | null |
type.string | string |
type.target | target |
Remarks
Runtime type inspection. type(value) returns a type-name string; whole numbers report int32 and fractional numbers report float. Compare common results with type.int32, type.float, type.string, type.bool, type.null, type.array, type.font, type.model, type.target, or type.handle. Structs and typed vision values return their specific type names, which do not have fixed type.* constants.
Examples
Use enums, functions, and type.atlas
enum Mode {
idle,
active = 5
};
function modeName(value) {
if (value == Mode::active) {
return "active";
}
return "idle";
}
var currentMode = Mode::active;
event on_frame() {
string numericType = type(currentMode);
ui.status(string.format("{} ({})", modeName(currentMode), numericType));
}