Jump to: navigation, search

Scripting Primer

Scripting 101

Cubiverse uses Java-script to make your worlds come alive, it supports ALL aspects of Java-script - so anything you read regarding pure Java-script will work.

However, you are not running your Java-script inside a web browsers - its running on a Cubiverse server. This means you do not have access to "document", "window" objects and JS calls provided by the browser such as setTimeout, createElement, console.log, etc.

But most of this does not mater, as Cubiverse is (mostly) an event driven system where your Java-script gets called when something happens. For example, when a player needs spawned, when a mob touches a certain cube, or when the world reaches a certain time of day.

Your Java-script is written into either one of two things:

Voxel Cubes - These are just normal cubes in the world, such as grass or snow.

Entity Cubes - These are invisible cubes that are used to handle behind the scene's actions.

Trigger Zones - These are invisible zones which can be used to trigger events should players enter or leave them.

Items - These are spawnable items that exist within your world, such as Torches or other tools.

Voxel Cubes

With voxel cubes you can add Java-script to affect what happens to the cube.

In the script editor you will have a Java-script object which is registered with Cubiverse as the code to run when something happens to the cube you are editing.

Your code will be triggered on some sort of event, such as a cube creation, player touching or walking on top of the cube. In the case of a cube that is acting as a lift, you will add a function called "onWalkOn" to your cube's object. When any player walks on the cube the code within the "onWalkOn" function will execute (and you will probably tell the Cube to start moving to it's destination location)

Entity Cubes

These cubes come in different types, each one tasked with a certain aspect of Cubiverse.

The world editor will allow you to select which type of entity you wish to place, but these include "Player Spawn", "Mob Spawn" and "Generic" entities.

Trigger Zones

These zones are 3D spaces in which events occur based on player interaction with them. You are free to size the trigger zones to any size you want, and attach events so that you can be notified if players enter to leave the zone. When these events occurs you received a Javascript player object (as an parameter) so you know who exactly triggered the event .


Cubiverse has a number of items that can be spawned anywhere in the world (even inside cubes), you can get events on when a player has picked up and equipped any item.


Whilst this page is meant as an easy introduction to Cubiverse scripting, it should be noted that you have the ability to perform complex operations including controlling multiple cubes, sending messages between scripts, etc. to generate an almost unlimited amount of functionality.