08-22-2013, 05:54 AM
Sounds good. Core is all done
Poll: Change the API? You do not have permission to vote in this poll. |
|||
Yes, break all the plugins | 6 | 85.71% | |
No, keep it as is | 1 | 14.29% | |
Total | 7 vote(s) | 100% |
* You voted for this item. | [Show Results] |
API change in hook-adding
|
08-22-2013, 05:54 AM
Sounds good. Core is all done
I don't like polluting the global namespace so much. The hooks are used so rarely that it's not worth the few saved keystrokes.
What is more intriguing is (yet another) function signature: cPluginManager.AddHook(HOOK_TYPE); -- CallbackFunction is assumed to be named the same as in the old APII'm still not sure, it'd make coding easier, but it's not good for maintenance, the line doesn't say anything about the function that will be called, it'd be confusing to the beginners.
For some reason I can't add hooks. I get these errors:
Code: [12:29:30] Plugin WorldEdit wants to add a hook (19), but it doesn't provide the callback function "OnPlayerBreakingBlock" for it. The plugin need not work properly. cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_BREAKING_BLOCK, SelectFirstPointHook); -- Add hook that gets called when selecting the first point. cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICK, SelectSecondPointHook); cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICK, RightClickCompassHook); cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICK, ToolsHook); cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_LEFT_CLICK, LeftClickCompassHook); -- Add hook OnPlayerLeftClick cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_LEFT_CLICK, SuperPickaxeHook); cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_JOINED, OnPlayerJoined); -- Add hook OnPlayerJoined cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_ANIMATION, OnPlayerAnimation); -- Add hook OnPlayerAnimation for left click compassBut it is fixed when I add function OnPlayerBreakingBlock() end function OnPlayerRightClick() end function OnPlayerLeftClick() end
08-22-2013, 09:42 PM
And those functions, SelectFirstPointHook etc, are they defined?
08-22-2013, 11:27 PM
Yes. They are in a different .lua file but they exist.
08-22-2013, 11:33 PM
Hmm, strange. Since the initialize function is called after everything has been loaded, the functions should be available as globals. They're not local, are they?
08-22-2013, 11:41 PM
The weird thing is that the server still searches for a function with the same name as before the API change
(HOOK_PLAYER_BREAKING_BLOCK and OnPlayerBreakingBlock) but when the server calls the hook it calls the function I said it should use (HOOK_PLAYER_BREAKING_BLOCK and SelectFirstPointHook)
08-22-2013, 11:43 PM
Oh, that might be the cause, the leftover code for hook function existence is based on the old API. I'll fix this later in the evening when I get home. I thought the old-named functions were called instead.
Thanks given by: NiLSPACE
Or not. I tried calling AddHook(cPluginManager.HOOK_CHAT, HookChat) with a HookChat function defined, and everything worked fine.
Could you send your plugin to me? I think I've fixed it. Try it now.
10-20-2013, 11:26 PM
You broke all plugins with that. Some of my plugins are not working, SignLock is not working, MCServer says it fix the call but plugins dont work.
|
« Next Oldest | Next Newest »
|