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 =;
	outputElement.textContent += args.join('\t') + '\n';