c++ - Creating properties for Lua -
i wasn't sure how word title, here go.
let's made lua function create 2d box appear on screen - example:
box = createobject("box")
how create properties box
subsequently change how box
looks or reacts? example may want do
box.positionx = 0 box.positiony = 60
how do in c++?
just answering direct question itself, things simple:
use standard metatable-aware add/set-table-index api.
if @ how box should look, things interesting:
- if
createobject "box"
returns lua table , don't need react on change, don't special. - if
createobject "box"
returns lua table need react immediately, let act proxy object, aka force using metatable function never adding element table itself. remap index or table saved @ dedicated index or in metatable/metatable function closures. - if
createobject "box"
returns userdata, same 2, maybe saving non-lua-values in c faster access/higher efficiency, using environment table other values.
Comments
Post a Comment