Creating Console Commands
From CryWiki
| ||||||||||||||
In this tutorial, we are going to create a console command in Crysis using Lua.
Contents |
Creating a Console Command with No Parameters
Creating the Lua Function
First, we will need a Lua function which is going to be called by the console command. Let's create a sample function called sayhellofunc:
|
| |
|---|---|
| |
Binding a Console Command to the Lua Function
System.AddCCommand binds a console command to a lua function.
|
| |
|---|---|
| |
The first argunemt ("sayhello") is the name of the console command. The second argument ("sayhellofunc()" is the name of the Lua function. The third argument is the description of the console command.
Creating a Console Command with Parameters
Creating the Lua Function
First, we will need a Lua function with parameters. Lets make a function that echos the parameters.
|
| |
|---|---|
| |
Binding a Console Command to the Lua Function
Now lets bind it.
|
| |
|---|---|
| |
In this code, %line is the parameter to the console command. Thus whatever was passed in as a argument is also passed into the Lua function.
Test it out
Typing echo hello world into the console and it should print "<Lua>hello world".
