02-03-2025, 12:54 AM
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:
Hooks.lua contains:
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:
Hhow to transfer an object to cLuaWindow and whether it is necessary?
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_WINDOW, OnOpeningWindow)
Hooks.lua contains:
PHP Code:
function OnOpeningWindow(Player, Window)
local OnClicked = function(Window, ClickingPlayer, SlotNum, ClickAction, ClickedItem)
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(Window, ClickingPlayer, SlotNum, ClickAction, ClickedItem)
LOG('Clicked')
end
local Window = cLuaWindow(cWindow.wtChest, 3, 3, 'TestChest')
Window:SetOnClicked(OnClicked)
Player:OpenWindow(Window)
Hhow to transfer an object to cLuaWindow and whether it is necessary?