Files
sbox-public/engine/Sandbox.Tools/ConsoleSystem.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

35 lines
1.1 KiB
C#

namespace Editor;
[SkipHotload]
public static partial class ConsoleSystem
{
/// <summary>
/// Try to set a console variable. You will only be able to set variables that you have permission to set.
/// </summary>
public static void SetValue( string name, object value ) => ConVarSystem.SetValue( name, value?.ToString(), true );
/// <summary>
/// Get a convar value as a string
/// </summary>
public static string GetValue( string name, string defaultValue = null ) => ConVarSystem.GetValue( name, defaultValue, true );
/// <summary>
/// Get a convar value as an integer if possible.
/// </summary>
public static int GetValueInt( string name, int defaultValue = 0 ) => ConVarSystem.GetInt( name, defaultValue, true );
/// <summary>
/// Get a convar value as an float if possible.
/// </summary>
public static float GetValueFloat( string name, float defaultValue = 0.0f ) => ConVarSystem.GetFloat( name, defaultValue, true );
/// <summary>
/// Run this command. This should be a single command.
/// </summary>
public static void Run( string command )
{
// Tools can do anything, let them run any command
ConVarSystem.Run( command );
}
}