Hello fellow ActionScript devs. Check out a library I made to define getters and setters on Lua tables.
https://github.com/joshtynjala/getset.lua
Simple example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | local getset = require( "getset" ) function createSimple2DPoint(x, y) local point = { x = x, y = y } getset.defineProperty(point, "length", { get = function() return math.sqrt( point.x * point.x + point.y * point.y) end -- setter is optional, use "set" to define one }) return point end local point = createSimple2DPoint(4, 4) print( point.length ) -- 5.6568542494924 |