Lua hooks needed!
#31
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?
Reply
Thanks given by:
#32
I'll have a look about that, in between of the hair-pulling 1.3.2 sessions.
Added in Rev 814, but...
[Image: 22457623.jpg]
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.
Reply
Thanks given by: Taugeshtu
#33
Getting NULLs in Lua is not a problem, in Lua NULL is equivalent to "nil" and it'll simply error on that. No segfaults Smile
Reply
Thanks given by:
#34
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 Wink

Oh, yeah, and OnBlockPlace and OnBlockDig are gone, so, really, breaking all pluginsTongue
Reply
Thanks given by:
#35
I will implement these when you have them finalised Smile

Also, is OnPlayerBreakingBlock going to fire when a player is in creative?

Also, the wiki is still broken Sad It says scoket error or something when i try and edit a page.
Reply
Thanks given by:
#36
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.
Reply
Thanks given by:
#37
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.
Reply
Thanks given by: bearbin , Taugeshtu
#38
What are the hooks so I can implement the new stuff?
Reply
Thanks given by:
#39
there should be another bugtracker but then only for lua hooks requests and bugs
Reply
Thanks given by:
#40
I could add another category, or even another project to the bugtracker if you really think that's necessary
Reply
Thanks given by:




Users browsing this thread: 14 Guest(s)