Repository navigation
Chat Commands
JonataOliveiraa edited this page Nov 14, 2026
·
1 revision
Intermediate
A ModCommand is written as in tModLoader: the name typed after /, who may
run it and what it does.
using Terraria;
using Terraria.ModLoader;
public class HealCommand : ModCommand
{
public override string Command => "heal";
public override CommandType Type => CommandType.Chat;
public override string Usage => "/heal [amount]";
public override string Description => "Heals the player";
public override void Action(CommandCaller caller, string input, string[] args)
{
int amount = 100;
if (args.Length > 0 && !int.TryParse(args[0], out amount))
throw new UsageException("The amount must be a number.");
caller.Player.Heal(amount);
caller.Reply($"Healed {amount}.");
}
}The player types /heal 50 in the game's chat. args has the words after the
name, lowercased unless IsCaseSensitive is true; input is the whole line.
Type |
Runs |
|---|---|
Chat |
on the device of whoever typed it, in single player and in multiplayer |
Server |
on the host, for any player who types it (not in single player) |
World |
Chat in single player, Server in multiplayer: the commands that change the world |
Console |
kept for tModLoader code; the phone has no server console |
caller.Player is the player who typed it, and caller.Reply(text, color)
answers in that player's chat (from the host, it goes to that player only).
-
throw new UsageException("message")answers with the message, in red (or the color given). Without a message, or with any other exception, the player seesUsage: <Usage>. - The game's
/helplists the mod commands after its own, with theDescription.CommandLoader.GetHelp(CommandType)gives the same list. - Two mods with the same command: the player picks one with
/<Mod>:<command>(the mod's internal name, in any case); typing just/<command>lists the choices.
Example: samples/ExampleModCSharp/Common/Commands (/item, /addTime and
/setSomeNumber, ported from tModLoader).
Bunny Loader wiki ·
Discord ·
Repository ·
BL Editor
Written for Bunny Loader 0.5.5-beta and Terraria Mobile 1.4.5.8.6.
Bunny Loader is not affiliated with Re-Logic or 505 Games.
