Facepunch / sbox-issues

176 stars 12 forks source link

Allow adding ConCmd's at runtime #6506

Open Coomzy opened 4 days ago

Coomzy commented 4 days ago

For?

S&Box

What can't you do?

I can't add a ConCmd at runtime

How would you like it to work?

public class Example : Component
{
    [Button]
    public void Register_RuntimeConCmdExample()
    {
        ConCmd.Add(typeof(Example), nameof(RuntimeConCmdExample), "ConCmd Registered at Runtime Example");

        // I think this would be cool for dynamic functionality
        ConCmd.Add("Dynamic_Example", () => Log.Info("I was registered at runtime!"), "Dynamic ConCmd Registered at Runtime Example");
    }

    public static void RuntimeConCmdExample()
    {
        Log.Info("I was registered at runtime!");
    }
}

What have you tried?

I have ways of stopping commands from working, but they still show up and clog up the console command search

Additional context

I have a lot of debug commands that won't work in package if you don't have permissions, so I don't really want people seeing it as it'll make potentially useful commands harder to find.

Also, I'd like to be able to create dynamic commands for various purposes. This is possible in the editor with heavy reflection but that's both restrictive and tedious

garrynewman commented 4 days ago

I'd love to see an actual good reason for this. Couldn't you have one debug command and use the arguments to create other commands?

Coomzy commented 4 days ago

If you have one debug command you're not going to have any help with what to type, you just have to know the magic inputs and then require manual parsing them.

I appreciate it's a niche feature, but the alternatives just seem kinda shit to me when the console can be so useful

MrBrax commented 3 days ago

this just sounds like wanting the autocomplete method back, would be neat