03-27-2021, 05:26 PM
(This post was last modified: 03-27-2021, 06:37 PM by LegendGuard.)
Hello, all!
It's the first time I've touched engine code to test something simple.
IMPORTANT NOTE: only modifies engine part.
1. Open a file called console.c in xonotic/darkplaces folder
2. Write the following in the line 842 (NOTE: This line is specific, if you see something not empty, don't do. The code may change in some time due to the development, so don't write inside the functions, write it outside the functions)
3. Write the following line to call the command function in the line 917 more or less where says "// register our commands":
4. Save console.c file and go to console MSYS2 (as I use Windows)
5. In the console, while you're in xonotic/darkplaces directory, write and execute make sdl-release
(optionally, you can use ./all compile -r when you're in xonotic directory but IT'S NOT RECOMMENDED, since it compiles all contents and is slow to check the results of your code in the engine)
NOTE: about make
sdl-release = xonotic-sdl
sv-release = xonotic-dedicated
You can compile graphical with glx or sdl interface or non graphical dedicated good for servers without a windowing system.
There are differences:
make sdl-release uses sdl2-config (in my system is version 2.0.12) (uses -ljpeg) - USE THIS COMMAND IN xonotic/darkplaces DIRECTORY -
./all compile sdl uses xonotic/misc/builddeps/win64/sdl/bin/sdl2-config (version 2.0.10) (doesn't use -ljpeg) - USE THIS COMMAND IN xonotic DIRECTORY -
You can see more info in the makefile
6. After compiled successfully, go to xonotic directory and run the game with ./all run
7. Press Shift + Esc, type hello and ENJOY!!!
It's the first time I've touched engine code to test something simple.
IMPORTANT NOTE: only modifies engine part.
1. Open a file called console.c in xonotic/darkplaces folder
2. Write the following in the line 842 (NOTE: This line is specific, if you see something not empty, don't do. The code may change in some time due to the development, so don't write inside the functions, write it outside the functions)
Code:
//LegendGuard first time using engine code 27-03-2021
/*
================
Con_Hello_f
================
*/
static void Con_Hello_f (void)
{
Con_Printf("HELLO XONOTIC! I'm LegendGuard, touching console code in the engine! :D\n");
return;
}
3. Write the following line to call the command function in the line 917 more or less where says "// register our commands":
Code:
Cmd_AddCommand ("hello", Con_Hello_f, "output a hello message");
4. Save console.c file and go to console MSYS2 (as I use Windows)
5. In the console, while you're in xonotic/darkplaces directory, write and execute make sdl-release
(optionally, you can use ./all compile -r when you're in xonotic directory but IT'S NOT RECOMMENDED, since it compiles all contents and is slow to check the results of your code in the engine)
NOTE: about make
sdl-release = xonotic-sdl
sv-release = xonotic-dedicated
You can compile graphical with glx or sdl interface or non graphical dedicated good for servers without a windowing system.
There are differences:
make sdl-release uses sdl2-config (in my system is version 2.0.12) (uses -ljpeg) - USE THIS COMMAND IN xonotic/darkplaces DIRECTORY -
./all compile sdl uses xonotic/misc/builddeps/win64/sdl/bin/sdl2-config (version 2.0.10) (doesn't use -ljpeg) - USE THIS COMMAND IN xonotic DIRECTORY -
You can see more info in the makefile
6. After compiled successfully, go to xonotic directory and run the game with ./all run
7. Press Shift + Esc, type hello and ENJOY!!!