Skip to content

"Skeleton" entries for Unavailable Commands #6

@ckx

Description

@ckx

Some commands aren't usable when a game is initially launched, because they rely on members of classes which aren't instantiated yet (especially for debug stuff). I dislike that these commands are not added to the commands output, so in one game project, I wrote a helper function to add unavailable commands to the console.

            InitialConsoleCommands.Add("Scene", new List<string[]>() { new string[2] { "list_scene_entities", "Lists all entities currently in a scene." } } );
            InitialConsoleCommands.Add("DrawSystem", new List<string[]>() { new string[2] { "draw_hitboxes", "Draws all hit / hurt boxes on screen." },
                new string[2] { "draw_wireframe", "Enables wireframe mode."} });

            foreach (KeyValuePair<string, List<string[]>> kvp in InitialConsoleCommands) {
                foreach (string[] sa in kvp.Value) {
                    devConsole.AddCommand(sa[0], delegate {
                        devConsole.Log($"Unavailable command. {kvp.Key} object is required before usage.");
                    }, sa[1]);
                }
            }

This is a problem that might be better solved in the game console library. A simple "AddUnavailableCommand" would do.

  • Unavailable commands should be indicated as "Not yet usable" or something in the output of commands
  • When a new command is added to the main commands map, it should iterate over all the unavailable commands, and remove the appropriate "unavailable" element.

While doing this, consider loading commands from a data file to make the whole skeleton command process simple across different projects (and to keep command documentation out of code).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions