// ChatCommandRouter.cs using Simuspaces.Simulation; using UnityEngine; public class ChatCommandRouter : SimuScriptBase { public string commandName = "/roll"; public int defaultSides = 6; public int maxSides = 100; public override void Start() { RegisterChatCommand(commandName, OnRollCommand); Log("Listening for chat command " + commandName); } void OnRollCommand(SVChatCommandInfo command) { int sides = defaultSides; if (command.Args != null && command.Args.Length > 0) int.TryParse(command.Args[0], out sides); sides = Mathf.Clamp(sides, 2, Mathf.Max(2, maxSides)); int result = Random.Range(1, sides + 1); SendScriptChat(command.Username + " rolled " + result + " on d" + sides + "."); Log( "Handled " + command.FullText + " from " + command.Username + " uid=" + command.UserId + " args=" + command.ParameterText); } }