Hook for detecting click in cWindow, currently only cLuaWindow
#1
Created a branch on github that contains changes for a hook to detect and deny the click action in cLuaWindow.
Branch:
https://github.com/Seadragon91/cuberite/...ndow_click

The hook function has this params:
Code:
function MyOnWindowClicking(Player, LuaWindow, ClickedItem, ClickAction, SlotNum)

The ClickAction is already in available on lua side.
I created a example plugin that opens a lua window with command /openit. It contains a few items that runs a command / open a window on clicking it. The window is generated from the ini file in the plugin folder.

The biggest question is now do we want to detect a click in all windows? Brewing stand, furnace, crafting table, minecart with chest?
If yes then we need to add something with that we can get the owner of the window (block entity, minecart entity) and we would need to export all windows to lua.

In plugin SkyBlock I added a challenge window as test, works same like in a java skyblock plugin that I created years ago. Can be opened with "/challenges inv"
https://github.com/Seadragon91/SkyBlock/...indow_test
Reply
Thanks given by:
#2
The cWindow class is already exported exactly for this purpose: https://api.cuberite.org/cWindow.html ; there's no need to export any specific window types, and we don't need the window owner just yet.
Reply
Thanks given by:
#3
Well how can I get the content of the window?
Reply
Thanks given by:
#4
I think lua window is good enough for changing the content, the most plugins creates a custom window.
The current use I see to deny changing the content of non lua windows, would it to make then content only viewable and there it's still possible to have the clicked item.
Reply
Thanks given by:
#5
No, the problem is that cLuaWindow is a specific one; if you want to call the hook for regular windows, there's no way to cast them to cLuaWindow.
Reply
Thanks given by:
#6
I tested the hook for regular windows and it works.
But for this I have a idea:
  1. Get the block entity that the player wants to open
  2. Deny the opening of the block entity
  3. Create a lua window with the content of the block entity
  4. Call cPlayer:OpenWindow to open it
  5. Now the hook will be called and combining a list containing the player and the block entity - everything should be possible
  6. If the player closes the window, the callback SetOnClosing can be used to write the content back
Reply
Thanks given by:
#7
Do we want the hook only for cLuaWindow or for regulars, too?
Reply
Thanks given by:
#8
Why would we even need it for cLuaWindow, when the plugin already has the cLuaWindow object and does set all the handlers. We need a universal hook for all windows.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)