
WebViews
HTML pages from your resource, drawn with transparency over the game.
Script
const view = new net.WebView('client/html/shop.html');
view.on('buy', item => net.emitServer('buy', item));
view.emit('money', 500);
view.focused = true; // mouse and keyboard go to the page
view.on('unfocus', () => view.destroy());
Page
Inside a page, net.on, net.off and net.emit are available.
<!doctype html>
<meta charset="utf-8">
<button id="buy">Buy</button>
<p id="money"></p>
<script>
net.on('money', amount => document.getElementById('money').textContent = amount);
document.getElementById('buy').onclick = () => net.emit('buy', 'armour');
</script>
Rules
- F8 always returns mouse and keyboard to the game.
- A page can load only files of its own resource. There is no internet access.
- Nothing is stored between sessions.
- At most 8 views. The game must run borderless or windowed.