Adding command to source?
#1
Hi,
I'm experimenting with adding a command to the source code (ex. showing a form with a pic on it when type(showmypic) from the console).
For a quik test..
I duplicated the 'void quit' function and named it 'void quit2' and added a line to the doc...xml.
From the console i typed quit2 and i see the the same thing as if i typed quit..so far so good! When i hit enter i get "unknown command:quit2(from console or builtin).
Am i missing a place to Define 'guit2' ?
I've been all over the codes and cfg's but i can't solve this.
Also checked forums and web.
I know it's hard to teach old dogs new tricks but thanx in advance )
stv
Thanks given by:
#2
Changing the source code is useless unless you compile a binary after the changes are made. Some things can be done with simply CubeScript, which only requires .cfg edits, others must be done via the source code which requires some C++ knowledge and a compiler for your system.

Here is an example of a identical command made from both; of course, more advanced things will require source edits and are not possible with just CubeScript:

CubeScript version:
myMessage = [echo Hello] // Typing /myMessage - in game will cause "Hello" to be printed onto the console.

C++ version:
void myMessage() {conoutf("Hello");}
COMMAND(myMessage, ARG_NONE); // Typing /myMessage - in game will cause "Hello" to be printed onto the console.

Although this is very basic, I hope it helps you get the idea anyways. In CubeScript, aliases are used as commands. In C++ for AC, the "COMMAND()" and "COMMANDN()" functions define new commands that can be used in game. These functions call on other C++ functions that actually get the job done. In this case, the function "COMMAND()" executes the function "myMessage()" which causes the function "conoutf()" to print "Hello" to the screen.
Thanks given by:
#3
Hi Bukz,
I've been able to compile with no prob.
The syntax was my hangup,this looks like it answers my ??'s.
THANX!,
stv

guess i'll put the hammer(looks at pc) away then )
Thanks given by: