CREATING YOUR FIRST COMMAND

This section is a quick reference for creating your first command. For more details about commands see Creating Commands


1. Go in the project folder where you want to create the command (e.g. Assets/Commands/), right click and select
Create -> Command Console -> Command Scriptable

Create Command


2. Enter a name for the scriptable and open the Inspector.

Create Command


3. In the Inspector enter the Command String (the string you'll have to type in the prompt to run the command) and click the Generate Code button.

Create Command


4. Once the code has compiled, click the Edit Code button to open the command code in Visual Studio, or open the file manually.
The file is located in the "Generated" folder where you placed the command scriptable
(e.g. Assets/Commands/Generated/).


5. Locate the ExecuteRoutine method and replace the highlighted section below with your code.

Create Command

One example could be:


  public override void ExecuteRoutine()

  {

    // [[KEEP_BLOCK]] ** Do not remove this **

  

    Echo("Hello world! The time is: " + System.DateTime.Now.ToString());

  

    // [[/KEEP_BLOCK]] ** Do not remove this **

  }

NOTE: Always place your code inside the [[KEEP_BLOCK]] tags, otherwise it will not be kept when you recompile the command. (See Creating Commands for more details)

NOTE: Never delete a [[KEEP_BLOCK]] tag.


6. Start the game and enter your command in the console. It will now execute your code.

Create Command