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:

  1. if createobject "box" returns lua table , don't need react on change, don't special.
  2. 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.
  3. if createobject "box" returns userdata, same 2, maybe saving non-lua-values in c faster access/higher efficiency, using environment table other values.

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -