Need Help for hooks
#1
Hi all, i have a problem. I don't understand how to do it right.
Need:
When opening the oven or chest, notice the movement of objects, and perform some actions before closing the window.
My code doesn't work because the hook doesn't have the necessary functions.
My code:

Init.lua contains:
PHP Code:
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_OPENING_WINDOWOnOpeningWindow

Hooks.lua contains:
PHP Code:
function OnOpeningWindow(PlayerWindow)
     local OnClicked = function(WindowClickingPlayerSlotNumClickActionClickedItem)
          LOG('Clicked')
          return true
     end
     Window
():SetOnClicked(OnClicked)
end 

I don't understand how to get a callback to track clicks or movements of objects in an open window.

if I open a new window unrelated to the chest or furnace block, then I can receive a callback.
It works, but the window is not attached to the chest block:
PHP Code:
local OnClicked = function(WindowClickingPlayerSlotNumClickActionClickedItem)
     LOG('Clicked')
end
local Window 
cLuaWindow(cWindow.wtChest33'TestChest')
Window:SetOnClicked(OnClicked)
Player:OpenWindow(Window

Hhow to transfer an object to cLuaWindow and whether it is necessary?
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)