diff options
| -rw-r--r-- | docs/create-a-module.md | 88 |
1 files changed, 17 insertions, 71 deletions
diff --git a/docs/create-a-module.md b/docs/create-a-module.md index 820e435..ae70905 100644 --- a/docs/create-a-module.md +++ b/docs/create-a-module.md @@ -20,10 +20,7 @@ Before start we suggest you to read [Documentation about modular structure](The- 1. Create a folder inside modules/ directory -2. Create a CMakeLists.txt file in the root path of your module -it will be automatically detected by cmake when you [re]configure your project. - -3. Now you can develop add anything to the main project, such as some scripts or +2. Now you can develop add anything to the main project, such as some scripts or even an entire library Note: we suggest to use the [directory structure](Directory-Structure) standards of AzerothCore to better organize your modules and be familiar with main project. @@ -32,13 +29,24 @@ Note: we suggest to use the [directory structure](Directory-Structure) standards 1. Before continue, we suggest you to follow our guide on how to create a script for AzerothCore -2. After you’ve created your script you’ve to create a .h file to handle the script loading. +2. After you’ve created your script you’ve to create a .cpp file to handle the script loading. For example ( Assuming you’ve created an src folder ): - **src/loader.h** + **my_custom_loader.cpp** + + ```cpp +// From SC +void AddMyCustomScripts(); - `void AddMyCustomScripts();` +// Add all +// cf. the naming convention https://github.com/azerothcore/azerothcore-wotlk/blob/master/doc/changelog/master.md#how-to-upgrade-4 +// additionally replace all '-' in the module folder name with '_' here +void Addmod_my_customScripts() +{ + AddMyCustomScripts(); +} +``` NOTE: AddMyCustomScripts is composed by: @@ -48,74 +56,12 @@ Note: we suggest to use the [directory structure](Directory-Structure) standards Scripts ( Suffix ) -3. Now you’ve to include your loader in your cmake using a simple MACRO ( Assuming that your script is called MyCustom.cpp ): - -``` -AC_ADD_SCRIPT("${CMAKE_CURRENT_LIST_DIR}/src/MyCustom.cpp") -AC_ADD_SCRIPT_LOADER("MyCustom" "${CMAKE_CURRENT_LIST_DIR}/src/loader.h") -``` - -First parameter is your module identifier - -Second parameter is the path of your loader header. - -Now you can add all scripts you want to your server just creating their instances inside AddMyCustomScripts() function, or using cmake macro above. - ### **Create a custom configuration file** if you need to add a custom configuration file to your module that will be installed with server, the steps are very simple. -Before starting, you should have created the loader files described previously. - -1. Create a world script with this basic structure: - - -``` - #include "Configuration/Config.h" - #include "ScriptMgr.h" - - class MyWorldScript : public WorldScript - - { - public: - - MyWorldScript() : WorldScript("MyWorldScript") { } - - void OnBeforeConfigLoad(bool reload) override - { - if (!reload) { - std::string conf_path = _CONF_DIR; - std::string cfg_file = conf_path + "/my_custom.conf"; - sConfigMgr->LoadMore(cfg_file.c_str()); - } - } - }; - - void AddMyWorldScripts() - { - new MyWorldScript(); - } -``` - -2. Add your AddMyWorldScripts to your CMakeLists.txt created before - -3. Create a cmake file that must be loaded after binary installation and add this to your module CMakeLists.txt: - - ``` - ADD_HOOK(AFTER_WORLDSERVER_CMAKE "${CMAKE_CURRENT_LIST_DIR}/after_ws_install.cmake") - ``` - - of course you can call your file as you want , the AFTER_WORLDSERVER_CMAKE hook will be launched as soon as AzerothCore prepare the worldserver installation. - -4. Inside this new cmake file you’ve to put this instructions: - -``` -install(FILES "${CMAKE_SOURCE_DIR}/your_path/my_custom.conf.dist" DESTINATION ${CONF_DIR}) -``` - -Change "your_path" part with path to your conf file, for example: - -/modules/my_module/conf/my_custom.conf.dist +1. Add a file with the extension `.conf.dist` in folder `./conf` +2. Done. Yes, really, that's all there is to it. ### **Add your db files to db_assembler** |
