Moonshine

How to capture output from print()

Moonshine directs standard output data to the shine.stdout.write() function. By default, this function does nothing, but overwrite it with your own function and you can do anything with your Lua code's output.

var vm = new shine.VM(),
	outputElement = document.querySelector('pre.output');

shine.stdout.write = function () {
	var args = Array.prototype.slice.call(arguments);
	outputElement.textContent += args.join('\t') + '\n';
}

vm.load('./lua/my-script.lua.json');