Docs / Making content / HTML textures
The basic idea
Your page is normal HTML with a <script>. The game gives it one global object, window.omsi
(you can also just write omsi), and the page uses it for three things:
- Read what the bus is doing: speed, doors, the current line, the next stop.
- Write back: set a script variable, press a trigger, choose a route.
- React to touches and clicks on the texture.
The smallest useful page:
<div id="speed">--</div>
<script>
window.omsi = window.omsi || {};
window.omsi.update = function (d) {
document.getElementById('speed').textContent = d.vehicle.motion.speedKmh + ' km/h';
};
</script>The game calls omsi.update whenever something the page could care about has changed. You
don't poll. You wait for update, look at the data and redraw what you need.
Something wrong or missing? Fix it on GitHub or open an issue.