widget.* to druid.widget lls class

This commit is contained in:
Insality
2025-03-16 17:44:08 +02:00
parent ad0447b649
commit 5348561d68
17 changed files with 64 additions and 42 deletions

View File

@@ -148,4 +148,25 @@ function M.register_druid_as_widget(druid)
end
---Unregister a druid instance from the current game object.
function M.unregister_druid_as_widget()
local gui_url = msg.url()
local socket = gui_url.socket
local path = gui_url.path
local fragment = gui_url.fragment
for index = 1, #REGISTERED_GUI_WIDGETS[socket] do
local gui = REGISTERED_GUI_WIDGETS[socket][index]
if gui.path == path and gui.fragment == fragment then
table.remove(REGISTERED_GUI_WIDGETS[socket], index)
break
end
end
if #REGISTERED_GUI_WIDGETS[socket] == 0 then
REGISTERED_GUI_WIDGETS[socket] = nil
end
end
return M