Skip to content

OLD: Documentation

Andre Issa edited this page Sep 1, 2021 · 1 revision

Module Contents

Variables

ModUtil.config.AutoCollapse boolean If ModUtil will automatically check for tables that need to be collapsed when changed by ModUtil functions
ModUtil.Mods table List of the registered mod objects in the order registered in
ModUtil.Overrides table List by mirrored index of information about mods that override the value.
ModUtil.WrapCallbacks table List by mirrored index of information about mods that wrap the function.
ModUtil.PerFunctionEnv table List by mirrored index of duplicated function environments.
ModUtil.Anchors table Contains all the screen components that are created and managed by ModUtil and their data
ModUtil.GlobalConnector table String that replaces "." when converting paths to global elements (default "__")
ModUtil.FuncsToLoad table Functions that will be ran once on the next load.
ModUtil.MarkedForCollapse table Tables that will be collapsed on the next load.
ModUtil.Transistor table Table of Transistor specific contents, will be nil if the game isn't Transistor.
ModUtil.Pyre table Table of Pyre specific contents, will be nil if the game isn't Pyre.
ModUtil.Hades table Table of Hades specific contents, will be nil if the game isn't Hades.

Setup Functions:

ModUtil.RegisterMod( modName, parent ) Registers/creates a global (or parent sub) table , adds it to save ignores, and tracks it.
ModUtil.GlobaliseModFuncs( modObject ) Creates globals that point to every extant function in the mod (so buttons can call them)

Data Functions:

ModUtil.ValueString( o ) Returns string formated for displaying this object as the value of a table
ModUtil.KeyString( o ) Returns string formated for displaying this object as the key of a table
ModUtil.TableKeysString( o ) Returns a string displaying the keys of the table
ModUtil.ToString( o ) Returns recursive string representation of object for display
ModUtil.ToStringLimited( o, n, m, t, j ) Returns string representation of object for display, reduced if a table: up to n items from the m'th item onwards (both parameters can be given as tables to specify for different recursion depths), of type matching the string in t[j] or any type if t[j] = true or if t[j][type], recurses while incrementing j if t has more elements.
ModUtil.ChunkText( text, chunkSize, maxChunks ) Splits text into a table of lines so that the text fits in a certain size
ModUtil.InvertTable( Table ) Takes a table and returns an inverse index of that table
ModUtil.NewTable( Table, key ) Creates a new empty table at Table[key] if there isn't already something there
ModUtil.SafeGet( Table, IndexArray ) Takes a table and optionally an array of sequential indexes and gets the value at the end of the chain or nil if an index doesn't exist
ModUtil.SafeSet( Table, IndexArray, Value ) Takes a table and required array of sequential indexes and sets the value at the end of the chain or does nothing if an index doesn't exist
ModUtil.PathGet( Path ) Returns the value at the path.
ModUtil.PathSet( Path, Value ) Sets the value at the path.
ModUtil.MapNilTable( InTable, NilTable ) Takes a table and maps all of the chained entries of NilTable that exist in InTable to nil
ModUtil.MapSetTable( InTable, SetTable ) Takes a table and maps all of the chained entries of SetTable to entries in InTable
ModUtil.PathNilTable( Path, NilTable ) Takes a table at the path and maps all of the chained entries of NilTable that exist in it to nil
ModUtil.PathSetTable( Path, SetTable ) Takes a table at the path and maps all of the chained entries of SetTable to entries in it
ModUtil.GlobalisePath( Path ) Takes a path and creates a global at the joined path that points to the object at the path.
ModUtil.GlobaliseFuncs( Table, Path ) Takes a table and creates globals that point to every function in it (so buttons can call them). Path must be the path to the table.
ModUtil.Override( baseTable, IndexArray, Value, modObject ) Stores the current value of the item in the base table at the end of the index chain into ModUtil along with the new value and the mod object, then overwrites the value.
ModUtil.Restore( baseTable, IndexArray ) Restores the previous value of the item in the base table at the end of the index chain since the last override. Returns the current override.
ModUtil.BaseOverride( basePath , Value, modObject ) Stores the current value of the global at Path into ModUtil along with the new value and the mod object and overwites the value.
ModUtil.BaseRestore( basePath ) Restores the previous value of the global at Path since the last override. Returns the current override.

Interrupt Functions

ModUtil.LoadOnce( triggerFunction ) Adds the supplied function to a list of functions to be loaded exactly once on the next load
ModUtil.LoadFuncs( triggerArgs ) Loads the internal list of functions exactly once supplied with triggerArgs
ModUtil.WrapFunction( funcTable, IndexArray, wrapFunc, modObject ) Finds the function at the end of the index chain in the given table, a local function, and an optional global mod object and wraps the provided function around the table function, stores callbacks and retains the old references
ModUtil.RewrapFunction( funcTable, IndexArray ) Takes a function at the end of the index chain in the given table, iterates its the WrapCallback stack, reconstructing the wraps on top of a possibly changed base function.
ModUtil.UnwrapFunction( funcTable, IndexArray ) Restores the function at the end of the index chain in the given table to what it was before the latest wrap. Returns the current wrap.
ModUtil.WrapBaseFunction( baseFuncPath, wrapFunc, modObject ) Takes the path to a global function, a local function, and an optional global mod object and wraps the provided function around the base function, stores callbacks and retains the old references
ModUtil.RewrapBaseFunction( baseFuncPath ) Takes the path to a global function, iterates over its WrapCallback stack, reconstructing the wraps on top of a possibly changed base function.
ModUtil.UnwrapBaseFunction( baseFuncPath ) Restores the global function at the end of path to what it was before the latest wrap. Returns the current wrap.

Management Functions

ModUtil.IsUnKeyed( Table ) Takes a table and returns whether it has no non-numeric keys
ModUtil.AutoIsUnKeyed( Table ) Takes a table and returns whether it has no non-numeric keys used internally by ModUtil based on config
ModUtil.MarkForCollapse( Table, IndexArray ) Takes a table and optionally an array of sequential indexes and marks the table at the end of the chain for collapsing by ModUtil
ModUtil.CollapseMarked() Collapses all the tables marked by ModUtil and clears the list of tables marked for collapse ModUtil automatically collapses marked tables on every load
ModUtil.JoinIndexArrays( A, B ) Joins the index array B to the end of the index array A
ModUtil.PathArray( Path ) Converts a path (string sequence of indexes separated by ".") to an index array (sequence of indexes in a table)
ModUtil.JoinPath( Path ) Joins a path (string sequence of indexes separated by ".") by replacing each "." with the global connector (default "__")

Hades Specific Contents

ModUtil.Hades.PrintStackHeight Number of lines of text visible the next time a fresh print stack is created
ModUtil.Hades.PrintStackCapacity Number of lines of text stored in the buffer of the next fresh print stack created
ModUtil.Hades.PrintStackChunks( text, linespan, delay, color, bgcol, fontsize, font, sound ) Prints block/paragraph text to a list visible on a panel at the base of the screen. (Displays multiple prints at once)
ModUtil.Hades.PrintStack( text, delay, color, bgcol, fontsize, font, sound ) Prints text to a list visible on a panel at the base of the screen. (Displays multiple prints at once)
ModUtil.Hades.PrintDisplay( text , delay, color ) Prints text to the top of the screen. (Can only display one at a time)
ModUtil.Hades.PrintOverhead(text, delay, color, dest) Prints text above dest (defaults to the player). (Can only display one at a time)
ModUtil.Hades.OpenMenu( group, closeFunc, openFunc ) Begins setup for opening a Menu of a unique group name, closeFunc is called after the menu is closed and after a room transition (which closes all menus forcibly)
ModUtil.Hades.PostOpenMenu( group ) Ends setup for opening a ModUtil Menu, run after you have attached all the components you want to the menu.
ModUtil.Hades.CloseMenu( screen, button ) Safely closes a Menu without breaking input or other menus and calls the closeFunc.
ModUtil.Hades.DimMenu( screen ) Adds a dim layer behind the screen, must be run before other elements so it is drawn behind them.
ModUtil.Hades.UndimMenu( screen ) Makes the dim added by DimMenu completely transparent (to keep the layer order the same)
ModUtil.Hades.NewMenuYesNo( group, closeFunc, openFunc, yesFunc, noFunc, title, body, yesText, noText, icon, iconScale) Creates a stackable Yes/No dialog, use may require a tutorial unto itself.
ModUtil.Hades.CloseMenuYesNo( screen, button ) Closes a Yes/No dialog, called after any of its three buttons are pressed.