With the Modbox ‘docs’ site now offline (due to reasons outside of my control – though the archived.org version still kinda works) I wanted to post how the scripting language worked and why we made it.
Modbox has a visual scripting language called ‘MBScript’ – a drag and drop block based language for programming in VR:
Video tutorial on how to use it to script in Modbox 2.0:
It was developed over a few years with constant player feedback to replace the old original ‘wire tool‘ we developed for Modbox 1.0. The ‘wire tool’ was used ingame to connect objects together and do some basic event basic scripting – very similar to other building games like LittleBigPlanet/Dreams, or what players have done with Minecraft’s ‘Redstone’. This kind of scripting worked fine for when Modbox was just used for building simple puzzles and Rube Goldberg-esque contraptions – but once we started building actual game mechanics (like AI / state machines) it was clearly limited to a compared actual scripting language.
We could have implemented a existing language like Javascript/Lua – but our main focus was allow the player to script in VR, so any existing text based language wouldn’t work. We also wanted to make sure it was as easy to use as the old ‘wiring tool’ so non-programmers could create multiplayer games.
We also could have kept expanding the existing wiring system adding more nodes and options to make it closer to ‘Unreal Blueprints’ kind of functionality. One thing we realized though was that while it was great to be able to wire objects together in 3d – anytime you wanted to actually do complex logic it was better done with 2d nodes. There was no advantage to having to position and wire together a bunch of math functions together in 3d when it would have been much easier to parse in 2d. We also thought node based approaches just naturally become a mess over time when trying to do anything complex.
So we decided to go towards the Scratch / Blockly direction – which kept scripting closer to text, but also allowed beginner programmers to not have to deal with syntax or compile errors.
A large inspiration was actually a April Fools concept by Der Kevin showing ‘Unity Go‘ – a touch/mobile version of Unity with block based programming. A key part of that was the ability to switch from text to blocks (though in his example it was from C# to blocky style, which would have been near impossible to do and support all C# syntax).
Another inspiration was this post on Learnable Programming – which caused us to make sure MBScript was a living coding environment that was easy to understand and mess with. You should be able to live edit everything and visually see the flow of logic and values.
My first test was trying to remake the Superhot ‘time moves when you move’ mechanic. I then expanded it so it could be used to control AI based on voice commands.
Then a later massive change was the focus on allowing for switching back and forth to text. What we found was while usually the drag and drop interface was better than text (even for us, but especially for new programmers) we still wanted to the ability to do large changes by copy/pasting.
The C# type system is used to the limit the dropdown options, and validate the drag and drop blocks. If you are setting the value of a text variable, the drop down options are then limited to easily select text values/methods.
The goal of Modbox was to allow for making multiplayer games easily – so the scripting language needed to abstract anyway all the usual ‘client/server’ stuff of network programming. All code ran on the server, and updated the clients whenever values changed / methods were run. Optionally code could be set to run as ‘client side’ though, which was useful in the case of adding effects (where you want the response to be immediate, not wait for server to get a ‘damage’ effect when hitting a enemy).
It also needed to be editable in multiplayer – all changes to code sync online and allow multiple people to edit the same code at once (because of the block based approach this was actually a lot easier to do than trying to do multiplayer text like Google Docs).
After a few years of semi-development with the player community (and about 2-3 completely restarts with new syntax), it was released with the Modbox 2.0 release.
Here is a archive of the MBScript documentation.