-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move method registry and implement Custom Method template files
- Loading branch information
Showing
5 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2010 - 2024 Eluna Lua Engine <https://elunaluaengine.github.io/> | ||
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2010 - 2024 Eluna Lua Engine <https://elunaluaengine.github.io/> | ||
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2010 - 2024 Eluna Lua Engine <https://elunaluaengine.github.io/> | ||
* 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<Player> 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<Player>::SetMethods(E, CustomPlayerMethods); | ||
}; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2010 - 2024 Eluna Lua Engine <https://elunaluaengine.github.io/> | ||
* 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 |