docs
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
local _situations = {}
|
||||
|
||||
--- Registers a situation definition.
|
||||
-- @param situation table The situation data table.
|
||||
function Situation.register(situation)
|
||||
if not situation or not situation.id then
|
||||
PopupWindow.show({"Error: Invalid situation object registered (missing id)!"})
|
||||
@@ -8,16 +10,24 @@ function Situation.register(situation)
|
||||
if not situation.handle then
|
||||
situation.handle = function() end
|
||||
end
|
||||
if not situation.update then
|
||||
situation.update = function() end
|
||||
end
|
||||
if _situations[situation.id] then
|
||||
trace("Warning: Overwriting situation with id: " .. situation.id)
|
||||
end
|
||||
_situations[situation.id] = situation
|
||||
end
|
||||
|
||||
--- Gets a situation by ID.
|
||||
-- @param id string The situation ID.
|
||||
-- @return table The situation table or nil.
|
||||
function Situation.get(id)
|
||||
return _situations[id]
|
||||
end
|
||||
|
||||
--- Applies a situation.
|
||||
-- @param id string The situation ID to apply.
|
||||
function Situation.apply(id)
|
||||
local situation = Situation.get(id)
|
||||
if not situation then
|
||||
@@ -34,4 +44,3 @@ function Situation.apply(id)
|
||||
Context.current_situation = id
|
||||
situation.handle()
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user