Example mod · theonaris.examples.sphere-block 1.0.0
Glow Sphere Block
Adds a sphere block imported from an FBX model with its own texture, icon and placement sound. Spheres light up and shift from cyan to red the faster their creation moves.
A new building block made from an FBX model with its own texture, icon and placement sound, plus Lua logic that makes every sphere glow brighter and redder the faster its creation moves.
| You will learn | Where |
|---|---|
| Declaring a block in JSON, based on one of the game's own blocks | content/blocks/glow-sphere.json |
Importing a model (.fbx; .glb, .gltf and .obj work the same way) | models/glow-sphere.fbx |
| Overriding the model's texture and giving the block a palette icon | "texture", "icon" |
| Reacting to blocks appearing and disappearing | building.onPlaced, building.onRemoved |
| Lights, particle effects and per-player settings | world.empty, addLight, effects.burst, mod.settings |
| Adding a developer console command | devtools.command |
Try it
- Copy this folder into your mods folder (in the game: Mods → Open folder).
- Start the game, open Mods, and allow its permissions the first time: Review permissions, Allow, then Apply changes. It asks because it puts lights and effects in the world (
world). - Enter the building editor. The Glow Sphere is in the Basic category.
- Build something that moves and watch the spheres go from cyan to red. Type
/sphere-block.countin the developer console to count them.
How it works
The block is data
mod.json points the blocks content type at content/blocks/*.json. Each file there is one block:
{
"id": "glow-sphere",
"name": "Glow Sphere",
"base": "Cube",
"model": "/models/glow-sphere.fbx",
"texture": "/textures/glow-sphere.png",
"icon": "/icons/glow-sphere.png",
"collider": "sphere"
}baseis the game block this one copies. A block is far more than a mesh (connection faces, paint, aerodynamics, mirroring), so a mod block starts as a copy of a real one. Based onCube, the sphere connects on all six faces. Base it onThrusterand it would really thrust.- Paths starting with
/are from the mod's root. Without the slash they are relative to the JSON file. - The model is scaled to fit one block cell and centred, so it does not matter what size it was exported at. Set
"fit": falseto keep the file's own size, or"modelScale"to adjust it. - The block's number in saves and network messages comes from its full id (
theonaris.examples.sphere-block:glow-sphere), so it is the same on every machine: creations with spheres save, load and sync without any code.
The behaviour is a script
scripts/client.lua runs on each player's machine. building.onPlaced("glow-sphere", fn) calls fn for every sphere that appears, whether placed, loaded or received. A timer updates a light per sphere, nearest first and capped by a setting, since lights cost performance.
Every object a mod creates (lights, effects, sounds, console commands) is removed automatically when the mod stops. There is no clean-up code.
Files
mod.json identity, permissions, settings, content
content/blocks/glow-sphere.json
models/glow-sphere.fbx 1 m UV sphere
textures/glow-sphere.png hex panels with glowing seams
icons/glow-sphere.png palette and mod-list icon
sounds/place.wav
scripts/client.luaMake it yours
- Swap
models/glow-sphere.fbxfor your own model (keep it under 50k triangles for a block). - Change
"base"to another block, such as"Wheel"or"Thruster", to inherit what it does. - Add a second file in
content/blocks/. Every JSON file there becomes a block. - Edit
scripts/client.luain the game's script editor and save: the mod reloads at once.
All files
| File | Size |
|---|---|
content/blocks/glow-sphere.json | 407 B |
icons/glow-sphere.png | 18 KB |
mod.json | 1 KB |
models/glow-sphere.fbx | 41 KB |
README.md | 4 KB |
scripts/client.lua | 4 KB |
sounds/place.wav | 78 KB |
textures/glow-sphere.png | 177 KB |