Configuring and using scripting
Another use for Zircon is the ability to programmatically manipulate your game during runtime.
By default, script execution is limited to only the creator of the game or group owner.
Adding Functions#
Functions in Zircon use the Zirconium language and thus are sandboxed + use the syntax of that language
import { ZirconServer, ZirconFunctionBuilder } from "@rbxts/zircon";import Log from "@rbxts/log";
const MyFunction = new ZirconFunctionBuilder("print_message") .AddArgument("string") .Bind((context, message) => Log.Info( "Zircon says {Message} from {Player}", message, context.GetExecutor() ));
// Zircon server is initialized via the init callZirconServer.Registry.Init( ZirconConfigurationBuilder.default() .AddFunction(MyFunction, [ZirconDefaultGroup.User]) .Build());
This will create a global print_message that all players can run.
Then if run in Zircon:

ZirconServer.Registryis the server registryZirconConfigurationBuilderis the builder class for zircon's own configuration.- Depending on your goal with Zircon, this configuration may look different. If you're only using it for logging purposes, you can use
ZirconConfigurationBuilder.logging()for the configuration. - If you want a quick setup, you can use
ZirconConfiguration.default()- which includes thecreator,adminandusergroups.
- Depending on your goal with Zircon, this configuration may look different. If you're only using it for logging purposes, you can use
ZirconFunctionBuilderhere is a builder class, in which allows you to configure the executable function.AddArgumentadds an argument type, internal types you can use a string id, such asstring,number,boolean,playerandunknown. This will infer the zircon function types for theBindfunction + enforce type checking when this function is called.Bindbinds the arguments to the function you provide, the first argument of the function is alwayscontext; which is the zircon runtime's context (useful for getting things like the executing player)
ZirconConfigurationBuilder.AddFunctiontakes aZirconFunction, whichZiroconFunctionBuilder.Build(...)returns. The second argument toAddFunctionis the groups that can execute this function. By default you should limit it toZirconDefaultGroup.Creator(which can be added viaZirconConfigurationBuilder.CreateDefaultCreatorGroup).
The default groups available to Zircon are Creator, Administrator and User. Creator is the place or group owner, Administrator is a group that requires explicit users and User is any user. It is recommended that you use Creator or Administrator for functions.