lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


John W <jwdevel@gmail.com> 于2023年7月28日周五 01:13写道:

> any "vec2" keyword or anything, just a global "vec2(x,y)" constructor
> function. However, I *do* want to be able to write "foo.x = 3", so
> there has to be some sort of awareness of ".x" syntax - maybe a
> metatable, similar to how the 'string' type has methods attached to

If vec2 is a "value type" rather than "reference type", you can't
change the value of it just like a string.
All the "vec2" are values.

So I suggest to use "foo = vec2(3, foo.y)" insteal of "foo.x = 3",
or you can use a simpler version "foo = vec2(3, foo)" .

-- 
http://blog.codingnow.com