Reading Lua Variables From Javascript Using Lua.vm.js
Im using the lua.vm.js javascript library in order to get some lua code to execute in javascript. The code works fine(its a very simple lua example) but I cant get any variables de
Solution 1:
X-posted from https://github.com/kripken/lua.vm.js/issues/18
Use my branch/fork; repl can be found at https://daurnimator.github.io/lua.vm.js/repl.html
When a Lua variable is exposed to javascript; it is exposed as a function object; with methods invoke/get/set/etc. See https://github.com/daurnimator/lua.vm.js/blob/master/lua.js#L523
Using your example; expose the object to javascript somehow. e.g. in lua:
window.mydata = data
window.mykey = key
Then in javascript:
v1 = window.mydata.get(window.mykey)
v2 = window.mydata.get("a").get("b")
console.log(v1)
console.log(v2)
Post a Comment for "Reading Lua Variables From Javascript Using Lua.vm.js"