FreneticLLC / FreneticScript

The Frenetic Scripting Engine (dll)
MIT License
4 stars 1 forks source link

Type definer command thingy #19

Open mcmonkey4eva opened 8 years ago

mcmonkey4eva commented 8 years ago

Requires https://github.com/FreneticXYZ/FreneticScript/issues/10 Syntax: definetype <Type> <Variables Map> <Tags Map> Example:

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?