How add a function to existing class
#1
hi there,

how i can add a function/parameter to a existing class like cPlayer?

Example:


cPlayer:getBedPos(World)
Reply
Thanks given by:
#2
You need to implement the function in C++ code, and in the .h file, mark it with an "// tolua_export" comment right after the declaration. Then you need to document the API - that's in the Server/Plugins/APIDump folder; the format should be pretty self-explanatory.
Reply
Thanks given by: moiko89
#3
(05-20-2017, 12:54 AM)xoft Wrote: You need to implement the function in C++ code, and in the .h file, mark it with an "// tolua_export" comment right after the declaration. Then you need to document the API - that's in the Server/Plugins/APIDump folder; the format should be pretty self-explanatory.


Okay thanks... do you know if other plugins exist for an example?
Reply
Thanks given by:
#4
What, you mean you want to add a method to a class from a plugin? That's impossible.
Reply
Thanks given by:
#5
No it's not, I did it before with cBlockArea: https://forum.cuberite.org/thread-569-po...l#pid15474

cPlayer was a bit harder to do. First I had to get rid of the metatable, put the function inside and then put the metatable in there again.
Reply
Thanks given by:
#6
It has such limits that it's not worth doing. I assume the original request is to make a plugin that adds an API function for other plugins to use, so this won't work. And as noted, the custom functions and variables may not survive for long.
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)