A type hint says what a variable, parameter or function result holds. Hints are never needed; untyped code works as before.
var hp: int = 10;
var target: vec3? = undefined; // ? also allows undefined
function hurt(n: real, from: vec3 = vec3_zero) -> bool { ... }
var path: array<vec3> = [];
var boss: obj_enemy = noone;
The types: real, int, bool, string, array (array<T>), struct, function, Studio's own types (vec3, quat, colour...), and object names. After var hp: or ) ->, completion lists them.
Warnings in Problems (yellow, they never stop a build):
- a value that doesn't match its hint:
var p: vec3 = vec2(1, 2);,hp = "ten", an argument to a hinted parameter, areturnin a function with-> type; - the wrong number of arguments to Studio's own functions and methods (
vec2(1, 2, 3),v.lerp(w)), and too many to a hinted function of the project; - a field or method a type doesn't have (
pos.lenght(), with the name it probably meant); - a type name that isn't one (
var p: vector3).
Studio only warns when it can tell what a value is; it says nothing about values it can't work out.
For GameMaker builds (see Studio's own types), one more warning: *can't tell if p is a vector*. GameMaker builds turn a + b into a vector add only when Studio can tell that a or b is a vector. In a function that works with vectors, a parameter used in + - * / that nothing tells Studio about gets this warning; give it a default value (p = vec3_zero) or a hint (p: vec3) and it goes away.
Related topics
Keys are shown as on the Mac: ⌘ Command, ⌥ Option, ⌃ Control, ⇧ Shift. Studio for Windows shows its own keys beside each menu item.