Cuberite Forum
Hook Question - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Hook Question (/thread-669.html)

Pages: 1 2 3 4 5


Hook Question - bearbin - 12-29-2012

In what order do hooks of different plugins get called? (If 2 plugins are called on the same hook) Is there a order or is it not specified?


RE: Hook Question - xoft - 12-29-2012

I think it's the same order in which the plugins were loaded, so basically, you can't rely on that at all.


RE: Hook Question - bearbin - 12-29-2012

Thanks, i suppose I'll just have to specify that in the install instructions for the plugin.


RE: Hook Question - NiLSPACE - 08-08-2013

I also got a question: Is there a way to see if a player pressed the left mouse button? OnPlayerLeftClick only gets called if the player clicked on a block/entity.


RE: Hook Question - xoft - 08-08-2013

OnPlayerLeftClick() should be called everytime MCServer receives a left-click packet (it also outputs "HandleLeftClick: {coords}" into the log in Debug mode). We cannot report anything more, simply because the client doesn't send anything.


RE: Hook Question - bearbin - 08-08-2013

Also - is there any way to get a full list of all the api functions with parameters and return values, and hopefully a description?


RE: Hook Question - NiLSPACE - 08-08-2013

It should be possible somehow because when someone uses left click other people should see the animation.


RE: Hook Question - bearbin - 08-08-2013

That might be the arm swing packet not left click (swinghack?).


RE: Hook Question - xoft - 08-08-2013

(08-08-2013, 05:56 AM)bearbin Wrote: Also - is there any way to get a full list of all the api functions with parameters and return values, and hopefully a description?

Unfortunately, no, Lua only knows the function names. It would be even impossible, because Lua doesn't really care about the number or types of parameters to functions, whatever you throw at the function, Lua just happily calls that function and it's the function's responsibility to check its parameters' types and count.

There's a non-automatic (human-only) way, though. Have a look at Bindings.cpp and ManualBindings.cpp, each has a function at their bottom registering the Lua API functions; find whatever function you want to know about and see how it's implemented. All our functions have the type and count checks in place, so it should be pretty obvious to know the parameter types and count. Heck, perhaps there's even a way to automate this (on Bindings.cpp only, since that is machine-generated) and produce some kind of minidocumentation.

As for the description, you need to see the appropriate .h file. Let's say, for example, that you want to know what cWorld:TryGetHeight() does. So you open up World.h and search for TryGetHeight, you will find line 131 - 132:
/// Retrieves the world height at the specified coords; returns false if chunk not loaded / generated
bool TryGetHeight(int a_BlockX, int a_BlockZ, int & a_Height);  // Exported in ManualBindings.cpp
I'd say that's pretty explanatory as for the purpose, but "Exported in ManualBindings" tells you that the Lua parameters are probably a bit different, so you still need to look at ManualBindings for implementation for details on the params / return values.


RE: Hook Question - NiLSPACE - 08-08-2013

Could you use the arm swing packet as left click?