-
Notifications
You must be signed in to change notification settings - Fork 0
FAQ
Q: What versions of Minecraft does RedScript support?
RedScript targets Minecraft 1.21.4+. The MC command validator uses the 1.21.4 command schema. Earlier versions may work but are untested.
Q: Does it support Bedrock Edition?
No. RedScript compiles to Java Edition datapacks (.mcfunction) and NBT structures. Bedrock's command syntax is different.
Q: Can I use RedScript with a modded server?
Yes, as long as the server supports vanilla datapacks. Paper, Purpur, and Fabric all work. Forge works if you have a datapack-compatible setup.
Q: Why do all statements need semicolons?
The parser requires explicit statement terminators. This avoids ambiguity in complex expressions and keeps the grammar simple. (Yes, even scoreboard_set(...) needs a ;.)
Q: Can lambdas capture outer variables?
Read-only captures are allowed. Capturing a mutable outer variable is a compile error:
let base: int = 100; // OK — read-only capture
let counter: int = 0;
let bad = () -> int {
counter = counter + 1; // ✗ Error: cannot capture mutable variable
return counter;
};Q: How does scoreboard work with temporary variables?
RedScript uses the rs objective (created in __load) for all compiler-generated temporaries ($t0, $t1, $const_N, etc.). These are global — there's no call stack. Each function call has isolated temp var names per call site (monomorphization), so sequential calls don't interfere.
Q: What's the difference between @tick and @tick(rate=20)?
-
@tick— function runs every server tick (20 times/sec at normal TPS) -
@tick(rate=20)— function runs every 20 ticks (once per second)
Rate is implemented via a counter in the rs scoreboard.
Q: What does __load do?
__load is auto-generated and registered in data/minecraft/tags/function/load.json. It runs when the datapack is (re)loaded and initializes the rs scoreboard and all $const_N values.
Q: Why use #fake_player names in scoreboard?
Fake players (names starting with #) are persistent scoreboard entries that don't correspond to real players. They're useful for global state that doesn't despawn when players leave.
Q: Can I mix RedScript with handwritten .mcfunction files?
Yes. RedScript generates files into data/<namespace>/function/. You can add your own functions to the same namespace by placing .mcfunction files there manually — they won't be touched by the compiler.
Q: How do I know if the optimizer is helping?
Run with --stats:
redscript compile game.rs --statsQ: The optimizer changed behavior — what happened?
This is a bug. The optimizer should never change observable behavior. Please open an issue with a minimal repro.
Q: Can I disable specific optimizer passes?
Not individually yet. Use --no-optimize to disable all passes.
Q: Do I need a running MC server to use RedScript?
No. The unit tests and normal compilation don't require a server. The integration tests (mc-integration) require a Paper server with the testharness plugin — see Integration Testing.
Q: How do I run just the unit tests?
npm test
# or
npx jest --testPathIgnorePatterns=mc-integration