diff --git a/methods/CMangos/CustomMethods.h b/methods/CMangos/CustomMethods.h new file mode 100644 index 0000000000..50ab827d0f --- /dev/null +++ b/methods/CMangos/CustomMethods.h @@ -0,0 +1,27 @@ +/* +* Copyright (C) 2010 - 2024 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.md for more information +*/ + +// This file is used for custom Lua methods, without needing to edit the existing method header files. +// This can also be used to override default methods without needing to edit existing methods. +// It follows the same structure as any other method header, except you can use RegisterCustomFunction +// to register multiple method tables in a single file. + +#include "ElunaTemplate.h" +#include "ElunaIncludes.h" + +#ifndef CUSTOMMETHODS_H +#define CUSTOMMETHODS_H + +namespace LuaCustom +{ + // See the CustomMethods header file in the TC method directory for an example. + inline void RegisterCustomFunctions(Eluna* E) + { + + }; +}; + +#endif diff --git a/methods/Mangos/CustomMethods.h b/methods/Mangos/CustomMethods.h new file mode 100644 index 0000000000..50ab827d0f --- /dev/null +++ b/methods/Mangos/CustomMethods.h @@ -0,0 +1,27 @@ +/* +* Copyright (C) 2010 - 2024 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.md for more information +*/ + +// This file is used for custom Lua methods, without needing to edit the existing method header files. +// This can also be used to override default methods without needing to edit existing methods. +// It follows the same structure as any other method header, except you can use RegisterCustomFunction +// to register multiple method tables in a single file. + +#include "ElunaTemplate.h" +#include "ElunaIncludes.h" + +#ifndef CUSTOMMETHODS_H +#define CUSTOMMETHODS_H + +namespace LuaCustom +{ + // See the CustomMethods header file in the TC method directory for an example. + inline void RegisterCustomFunctions(Eluna* E) + { + + }; +}; + +#endif diff --git a/LuaMethods.cpp b/methods/Methods.cpp similarity index 97% rename from LuaMethods.cpp rename to methods/Methods.cpp index b529a16bf1..7b2d28ad36 100644 --- a/LuaMethods.cpp +++ b/methods/Methods.cpp @@ -32,6 +32,9 @@ #include "VehicleMethods.h" #include "BattleGroundMethods.h" +// Custom methods +#include "CustomMethods.h" + void RegisterMethods(Eluna* E) { ElunaTemplate<>::SetMethods(E, LuaGlobalFunctions::GlobalMethods); @@ -112,5 +115,8 @@ void RegisterMethods(Eluna* E) ElunaTemplate::Register(E, "ObjectGuid"); + // Register custom functions + LuaCustom::RegisterCustomFunctions(E); + LuaVal::Register(E->L); } diff --git a/methods/TrinityCore/CustomMethods.h b/methods/TrinityCore/CustomMethods.h new file mode 100644 index 0000000000..9cfef3d951 --- /dev/null +++ b/methods/TrinityCore/CustomMethods.h @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2010 - 2024 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.md for more information +*/ + +// This file is used for custom Lua methods, without needing to edit the existing method header files. +// This can also be used to override default methods without needing to edit existing methods. +// It follows the same structure as any other method header, except you can use RegisterCustomFunction +// to register multiple method tables in a single file. + +#include "ElunaTemplate.h" +#include "ElunaIncludes.h" + +#ifndef CUSTOMMETHODS_H +#define CUSTOMMETHODS_H + +namespace LuaCustom +{ + // Define a custom method that returns the players name + int CustomPlayerMethod(Eluna* E, Player* player) + { + E->Push(player->GetName()); + return 1; + } + + // Create a custom player method registry + ElunaRegister CustomPlayerMethods[] = + { + // Add the custom player method to the registry + { "CustomPlayerMethod", &LuaCustom::CustomPlayerMethod }, + }; + + inline void RegisterCustomFunctions(Eluna* E) + { + // Append all the custom Player methods to the Player object + ElunaTemplate::SetMethods(E, CustomPlayerMethods); + }; +}; + +#endif diff --git a/methods/VMangos/CustomMethods.h b/methods/VMangos/CustomMethods.h new file mode 100644 index 0000000000..50ab827d0f --- /dev/null +++ b/methods/VMangos/CustomMethods.h @@ -0,0 +1,27 @@ +/* +* Copyright (C) 2010 - 2024 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.md for more information +*/ + +// This file is used for custom Lua methods, without needing to edit the existing method header files. +// This can also be used to override default methods without needing to edit existing methods. +// It follows the same structure as any other method header, except you can use RegisterCustomFunction +// to register multiple method tables in a single file. + +#include "ElunaTemplate.h" +#include "ElunaIncludes.h" + +#ifndef CUSTOMMETHODS_H +#define CUSTOMMETHODS_H + +namespace LuaCustom +{ + // See the CustomMethods header file in the TC method directory for an example. + inline void RegisterCustomFunctions(Eluna* E) + { + + }; +}; + +#endif