What the script editor is
The script editor is a text editor embedded inside the RollingQuest level editor. It lets you write Lua scripts that hook into game events and control what happens at runtime. Each script you create is stored as a named file inside your level project and can be attached to one or more game entities.The script-per-entity model
Every game entity in RollingQuest can have its own script:- Level — runs for the whole level (start, update, win, lose)
- Blocks — individual cube blocks in the world
- Sides — the faces of a block that a ball can roll across
- Items — collectible objects in the level
- Enemies — enemy entities
- Balls — the player-controlled ball(s)
- Decorations — visual decoration objects
Scripts are not executed directly. The game reads them and calls specific hook functions you define inside them when corresponding events occur. If a hook function is not defined in your script, the game simply skips that event for that entity.
Writing and attaching a script
Open the level editor
Launch RollingQuest and open the level you want to work on in the level editor.
Open the script editor
Open the Script Editor by pressing the C key or from within the “Script” panel of any entity. Pressing the C key automatically opens the Script Editor with all the scripts contained in the level. If you open it from the “Script” section of any entity, you can also select which script you want to link to that entity.
Create a new script
In the script editor, create a new script file and give it a descriptive name such as
level_intro or moving_block. The name identifies this script so you can attach it to entities and reference it with import, include, or require.Write your hook functions
Type your Lua code into the editor. Define the hook functions you need. The example below is a Level script that shows a message when the level starts:
Attach the script to an entity
Select the entity you want the script to run on (for example, the level itself). In its properties panel, find the Script field and enter the name of the script file you just created. Save your changes.
Loading other scripts: import, include, and require
As your project grows, you will want to split shared code into separate script files and load them from other scripts. Three global functions handle this.
include(scriptName)
include loads the contents of another script directly into the current script’s environment, as if you had typed the code inline. Use it to bring in shared constants, utility functions, or helper tables.
import(scriptName)
import loads a script and returns its contents as a table. This is useful when you want to access definitions from another script without polluting the current script’s namespace.
require(scriptName)
require loads a script as a module. If the script returns a value (using return at the top level), require gives you that return value. Unlike include, the same script is only loaded once per session — subsequent require calls return the cached result.
Debugging with the Logger
TheLogger namespace lets you print messages to the in-game logs console while you are testing your level in the editor. Log messages do not appear during normal gameplay — Logger.isEnabled is true only in editor mode, so your logging calls are silently ignored in the final published level.
The four log levels
| Function | When to use | Console style |
|---|---|---|
Logger.log(msg) | General output; no special styling | Default |
Logger.info(msg) | Informational messages about normal program flow | Styled as information |
Logger.warning(msg) | Something unexpected happened but execution continues | Yellow background |
Logger.error(msg) | A serious problem that needs your attention | Red background |
Examples
Your first complete level script
Here is a finished example you can copy into a new script file and attach to your level entity. It prints a log message in the editor, shows a welcome dialog to the player, and logs another message when the level is won.Logger.info messages as each hook fires.