Lua hooks needed! - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html) +--- Forum: Development (https://forum.cuberite.org/forum-13.html) +--- Thread: Lua hooks needed! (/thread-464.html) |
RE: Lua hooks needed! - Taugeshtu - 09-02-2012 This request is about OnUpdatingSign() hook. How am I supposed to get cPlayer handle in Lua with this callback? I would like to know, which player is placing sign with given text right now. Some voodoo magic with OnBlockPlace hook would be too complicated, could I have cPlayer parameter as well? RE: Lua hooks needed! - xoft - 09-02-2012 I'll have a look about that, in between of the hair-pulling 1.3.2 sessions. Added in Rev 814, but... The parameter has been added as the last parameter of the callbacks, and also it has been added to cWorld:UpdateSign() as its last parameter (technically, it is this function that calls the callbacks, so it needs to know from which player the change came). Also note that the player object may come NULL; I have no idea how Lua handles that nor how you can check for that. Ouch, now that I think about it, I think you will always get a NULL, my error, will fix that soon. There, Rev 816 should have it all. RE: Lua hooks needed! - FakeTruth - 09-02-2012 Getting NULLs in Lua is not a problem, in Lua NULL is equivalent to "nil" and it'll simply error on that. No segfaults RE: Lua hooks needed! - xoft - 01-06-2013 I'm now trying desperately to fix our broken OnBlockPlace / OnBlockDig framework. Right now I have this: OnPlayerLeftClick() - fires everytime we get a left-click packet; parameters are the raw packet data. Plugin may stop entire processing by returning true. OnPlayerRightClick() - same as OnPlayerLeftClick(), but for rclk. Plugin may stop entire processing by returning true. OnPlayerBreakingBlock() - called just before a player breaks a block, and really only breaks a block, nothing else lclk-related. Plugin may stop the breaking by returning true. OnPlayerBrokenBlock() - called just after a player has broken a block, and only when a block was really broken. Plugin cannot stop the breaking anymore, it's been already done. OnPlayerPlacingBlock() - called just before a player places a block. Plugin may stop the placement by returning true. OnPlayerPlacedBlock() - called just after a player placed a block. Plugin cannot stop the placement anymore, it's been already done. OnPlayerUsingBlock() - called just before a player uses a block (chest, furnace etc.). Plugin may refuse. OnPlayerUsedBlock() - called just after a player used a block (chest, furnace etc.). Plugin cannot refuse. Note that the client may still be displaying the UI - it's not about clising the UI window, it's about sending the "OpenWindow" packet. OnPlayerUsingItem() - called just before a player uses an item in their hand (Probably buckets? dunno exactly. Not for tools, those get the OnPlayerBreakingBlock et al). Plugin may refuse. OnPlayerUsedItem() - called just after a player used an item in their hand. Plugin cannot refuse. OnPlayerShooting() - called before a player uses a ranged weapon (not fully implemented yet) OnPlayerEating() - called before a player eats food (not fully implemented yet) OnPlayerTossingItem() - called before a player tosses an equipped item (Q keypress). Plugin may refuse, but has to fix things on the client (inventory mismatch) Also, I'm renaming a few hooks to match this schema. So basically, I'm breaking all plugins Oh, yeah, and OnBlockPlace and OnBlockDig are gone, so, really, breaking all plugins RE: Lua hooks needed! - bearbin - 01-06-2013 I will implement these when you have them finalised Also, is OnPlayerBreakingBlock going to fire when a player is in creative? Also, the wiki is still broken It says scoket error or something when i try and edit a page. RE: Lua hooks needed! - xoft - 01-06-2013 Yes, a Breaking will be guaranteed to have fired before each Broken, even in creative. I'm trying to commit my changes to a branch, but the net here is really slow and unstable. Oh, it got through, so now you can have a look ("branches/hooks" branch). It's not yet working properly, though, it seems. RE: Lua hooks needed! - xoft - 01-06-2013 I think I got most of the hooks working, some extended testing would be welcome. I still think it'd be good for this to stay on a branch for a while, I feel that some of the hooks may need additional parameters. Especially the OnPlayerPlacingBlock() / OnPlayerPlacedBlock() could use the BlockMeta param, but currently there's no way of getting it out of the cItemHandler. RE: Lua hooks needed! - bearbin - 01-06-2013 What are the hooks so I can implement the new stuff? RE: Lua hooks needed! - NiLSPACE - 01-06-2013 there should be another bugtracker but then only for lua hooks requests and bugs RE: Lua hooks needed! - FakeTruth - 01-07-2013 I could add another category, or even another project to the bugtracker if you really think that's necessary |