This commit is contained in:
@@ -3,29 +3,29 @@ DesitionManager = {}
|
||||
local _desitions = {} -- Private table to store all desitions
|
||||
|
||||
-- Registers a decision object with the manager
|
||||
-- desition_object: A table containing id, label, handle(), and condition()
|
||||
function DesitionManager.register(desition_object)
|
||||
if not desition_object or not desition_object.id then
|
||||
-- desition: A table containing id, label, handle(), and condition()
|
||||
function DesitionManager.register(desition)
|
||||
if not desition or not desition.id then
|
||||
PopupWindow.show({"Error: Invalid desition object registered (missing id)!"})
|
||||
return
|
||||
end
|
||||
if not desition_object.label then
|
||||
if not desition.label then
|
||||
PopupWindow.show({"Error: Invalid desition object registered (missing label)!"})
|
||||
return
|
||||
end
|
||||
|
||||
-- Ensure handle() and condition() methods exist with defaults if missing
|
||||
if not desition_object.condition then
|
||||
desition_object.condition = function() return true end
|
||||
if not desition.condition then
|
||||
desition.condition = function() return true end
|
||||
end
|
||||
if not desition_object.handle then
|
||||
desition_object.handle = function() end
|
||||
if not desition.handle then
|
||||
desition.handle = function() end
|
||||
end
|
||||
if _desitions[desition_object.id] then
|
||||
if _desitions[desition.id] then
|
||||
-- Optional: warning if overwriting an existing desition
|
||||
trace("Warning: Overwriting desition with id: " .. desition_object.id)
|
||||
trace("Warning: Overwriting desition with id: " .. desition.id)
|
||||
end
|
||||
_desitions[desition_object.id] = desition_object
|
||||
_desitions[desition.id] = desition
|
||||
end
|
||||
|
||||
-- Retrieves a desition by its id
|
||||
|
||||
Reference in New Issue
Block a user