function flowdefine MyVector^length_squared
{
var xsq = <{[this].x.multiply[<{[this].x}>]}>;
var ysq = <{[this].y.multiply[<{[this].y}>]}>;
var zsq = <{[this].z.multiply[<{[this].z}>]}>;
var result = <{[xsq].add[<{var[ysq]}>].add[<{var[zsq]}>]}>;
}
definetype MyVector x:0|y:0|z:0 length_squared:MyVector^length_squared;
var vec = <{myvector[x:1|y:2|z:3]}>;
echo <{[vec].x}>;
echo <{[vec].length_squared}>
Possibly setter thingies as well? And constructors?
Requires https://github.com/FreneticXYZ/FreneticScript/issues/10 Syntax:
definetype <Type> <Variables Map> <Tags Map>
Example:Possibly setter thingies as well? And constructors?