docs
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
--- Utility functions.
|
||||
Util = {}
|
||||
|
||||
--- Safely wraps an index for an array.
|
||||
-- @param array table The array to index.
|
||||
-- @param index number The desired index (can be out of bounds).
|
||||
-- @return number The wrapped index within the array's bounds.
|
||||
function Util.safeindex(array, index)
|
||||
return ((index - 1 + #array) % #array) + 1
|
||||
end
|
||||
|
||||
--- Navigates to a screen by its ID.
|
||||
-- @param screen_id string The ID of the screen to go to.
|
||||
function Util.go_to_screen_by_id(screen_id)
|
||||
local screen_index = Context.screen_indices_by_id[screen_id]
|
||||
if screen_index then
|
||||
@@ -11,4 +18,4 @@ function Util.go_to_screen_by_id(screen_id)
|
||||
Context.selected_decision_index = 1 else
|
||||
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found or not indexed!"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user