Closed Rybadour closed 7 years ago
Hi,
I've not heard of anyone attempting to use Moonshine with React Native before, so I'm rathing interested in your results.
From what you say, it looks like the JSON file is being loaded and executed fine. The error is from the runtime, which usually means there's an error in your Lua code. Could you attach the original Lua code that you're "distilling"?
From what I can read from the bytecode, I'm seeing arithmetic ADD operations and a number of strings. Could it be that you are performing maths operations on strings? ie. something like print('a' + 'b' + 'c')
, instead of print('a'..'b'..'c')
?
Also, in your call to initialise the VM, browsers (at least) would have an issue with the fact that the log()
function is not bound to the console
object. I don't know if that's an issue in React Native, but you may the following more helpful:
var luaVm = new shine.VM({
global: 42,
speak: console.log.bind(console),
});
Also, as there's not much development going on Moonshine these days, depending on what you're doing you may like to checkout Starlight too:
Ah that makes more sense now. I was looking at the JSON and thought it meant it had trouble with the first line of the JSON since it mentions "@src/lua/test.lua". Everything seems to working fine now!
I took a look Starlight and Moonshine but Moonshine seemed like a simpler solution.
I'm trying to use Moonshine in react-native and as such the only way I think I can get this to work is by passing the distilled JSON directly to the VM. However when I try this I get a strange error:
My code is pretty straight forward:
The distilled file is:
I couldn't find any documentation about this use case but while reading the source code this seems like the way to do this.
Thank you.