This page as Markdown: https://bloxd.io/docs/getting-started.md. Every page of these docs, for AI agents: https://bloxd.io/docs/llms.txt
Getting started
There are three places to write JavaScript in Bloxd: code blocks, code boards and World Code. Code in any of them controls the game through api, in custom games and worlds. Only players who can edit code (the canEditCode client option) can write it, but anyone can run a code block or board.
Please use our Discord to report problems or suggest features.
Code Blocks
- Find the Code Block by searching in the creative menu.
- Clicking a code block runs its code, unless you are crouching. Players who can edit code open its code by right clicking it.
- Running a code block or board also runs the code blocks and boards touching it, so clicking a
press to codeboard next to a code block runs it without opening the code editor. - A code block doesn't need a
press to codeline, and removes one if you add it.
Boards
- A board whose text starts with
press to codeon its own line runs the code below that line when someone clicks it. - Boards only hold a little text: use a code block for anything longer, or split the code across several boards.
World Code
World Code runs for the whole world instead of when someone clicks. Open it with F8. It defines Callbacks, such as tick and onPlayerJoin, which the game calls when things happen. The How-Tos build whole games with it.
Globals
| Name | Value |
|---|---|
api | The game API: every method in the API Reference |
myId | The ID of the player running the code, or null when nobody is, as in most World Code |
playerId | The same as myId |
thisPos | The position of the code block or board running the code, as [x, y, z] |
api.ownerDbId | The database ID of the world's owner, or null if it has none |
Logs and results
api.logandconsole.logdo the same thing: each shows its values in chat as aLog:message.- When the last line of a code block or board has a value, the player who ran it sees that value as a
Result:message.
Next steps
Snippets has short pieces of code to copy into a code block and change.