Versiones comparadas

Clave

  • Se ha añadido esta línea.
  • Se ha eliminado esta línea.
  • El formato se ha cambiado.
Comentarios: Updated guide to match current script system. See https://github.com/TrinityCore/TrinityCore/commit/b5369b7d874c337f49051f79dba9508f21a218de

...

Bloque de código
languagecpp
void AddSC_my_script(); // this is a declaration
AddSC_my_script();      // this is a call


Open the file: /src/server/gamescripts/Scripting/ScriptLoaderCustom/custom_script_loader.cpp and scroll to the bottom of it.
The declaration needs to be added
below the line that says/* This is where custom scripts' loading functions should be declared. */
H
ere is an example of how the code in ScriptLoader.cpp the file can look after adding the function declaration to it:

Bloque de código
languagecpp
#ifdef SCRIPTS 
//* This is where custom scripts' loading functions should be declared. */:
void AddSC_my_script(); 
#endif

Next you add the function call under the line that says /* This is where custom scripts should be added. */inside the function called AddCustomScripts
Again here is an example of how the code could look afterwards: 

Bloque de código
languagecpp
void AddCustomScripts(){
#ifdef SCRIPTS
     /* This is where custom scripts should be added. */
    // The name of this function should match:
// void Add${NameOfDirectory}Scripts()
void AddCustomScripts()
{
    AddSC_my_script(); 
#endif 
}

 Now

you need to link the script file to the compilation with cmake. Lets do that for our example script. Open up the file /src/server/scripts/Custom/CMakeLists.txt
Our script file is located in /src/server/scripts/Custom and it is called My_script.cpp so we need to add the line "Custom/My_script.cpp" to the file.
ExampleHere is a final example of how the file could look after both edits:

# file(GLOB_RECURSE sources_Custom Custom/*.cpp Custom/*.h) set(scripts_STAT_SRCS ${scripts_STAT_SRCS} # ${sources_Custom} "Custom/My_script.cpp" ) message(" -> Prepared: Custom")
Bloque de código
languagetext
cpp
// This is where scripts' loading functions should be declared:
void AddSC_my_script();


// The name of this function should match:
// void Add${NameOfDirectory}Scripts()
void AddCustomScripts()
{
    AddSC_my_script();
}

 

Next you need to use cmake and compile.

...