FrameworkZ API - FrameworkZ.Utilities

FrameworkZ.Utilities

library

Utility module for FrameworkZ. Contains utility functions and classes.

0
Functions
20
Methods
2
Fields

Fields

2
FrameworkZ.Utilities 📋 table
Utility module for FrameworkZ. Contains utility functions and classes.
Initial value: {}
FrameworkZ.Utilities.Directions 📋 table inferred
Initial value: { { dx = 1, dy = 0, wallFlag = IsoFlagType.collideW, doorFlag = IsoFlagType.doorW, windowFlag = IsoFlagType.windowW }, { dx = -1, dy = 0, wallFlag = IsoFlagType.collideW, doorFlag = IsoFlagType.doorW, windowFlag = IsoFlagType.windowW }, { dx = 0, dy = 1, wallFlag = IsoFlagType.collideN, doorFlag = IsoFlagType.doorN, windowFlag = IsoFlagType.windowN }, { dx = 0, dy = -1, wallFlag = IsoFlagType.collideN, doorFlag = IsoFlagType.doorN, windowFlag = IsoFlagType.windowN }, }

Methods

20

FrameworkZ.Utilities:CopyTable(originalTable, tableCopies, shouldCopyMetatable)

method
Copies a table.

Parameters

originalTable 📋 table
The table to copy.
tableCopies 📋 table
(Internal) The table of copies used internally by the function.

Returns

📋 table
The copied table.

FrameworkZ.Utilities:DumpTable(tbl)

method
Convert a table to a string representation.

Parameters

tbl 📋 table
The table to dump.

Returns

📝 string
String representation of the table.

FrameworkZ.Utilities:GetItemColor(item)

method
Extracts color information from a Project Zomboid item.

Parameters

item 📦 object
The InventoryItem to extract color from.

Returns

🔢 number
r Red component (0.0-1.0)
🔢 number
g Green component (0.0-1.0)
🔢 number
b Blue component (0.0-1.0)
🔢 number
a Alpha component (0.0-1.0)

FrameworkZ.Utilities:GetPrettyDuration(timeInSeconds)

method
Convert seconds to a human-readable duration string.

Parameters

timeInSeconds 🔢 number
The time in seconds.

Returns

📝 string
Pretty formatted duration (e.g., "1 day and 3 hours").

FrameworkZ.Utilities:GetRandomNumber(min, max, keepLeadingZeros)

method
Generate a random number between min and max.

Parameters

min 🔢 integer
Minimum value.
max 🔢 integer
Maximum value.
keepLeadingZeros (optional) ✅ boolean
If true, format with leading zeros.

Returns

🔢 integer | 📝 string
Random number (string if keepLeadingZeros).

FrameworkZ.Utilities:IsExterior(square)

method
Check if a square is exterior (no room).

Parameters

square 🏷️ IsoGridSquare
The square to check.

Returns

✅ boolean
True if exterior.

FrameworkZ.Utilities:IsSemiExterior(square)

method
Check if a square is semi-exterior (in a room but has path to exterior).

Parameters

square 🏷️ IsoGridSquare
The square to check.

Returns

✅ boolean
True if semi-exterior.

FrameworkZ.Utilities:IsTrulyInterior(square)

method
Check if a square is truly interior (no path to exterior without passing through walls/doors/windows).

Parameters

square 🏷️ IsoGridSquare
The square to check.

Returns

✅ boolean
True if truly interior.

FrameworkZ.Utilities:MergeTables(t1, t2, visited)

method
Merge two tables recursively.

Parameters

t1 📋 table
The target table to merge into.
t2 📋 table
The source table to merge from.
visited (optional) 📋 table
Internal tracking for circular references.

Returns

📋 table
The merged table (t1).

FrameworkZ.Utilities:OrderedNext(t, state)

method
Internal: Iterator function for ordered table traversal.

Parameters

t 📋 table
The table being iterated.
state 🏷️ mixed
The current state (previous key).

Returns

🏷️ mixed
\mixed Next key and value.

FrameworkZ.Utilities:OrderedPairs(t)

method
Iterate table in sorted key order.

Parameters

t 📋 table
The table to iterate.

Returns

⚡ function
\table \nil Iterator function, table, and initial state.

FrameworkZ.Utilities:Pack(...)

method
Pack variadic arguments into a table with count.

Returns

📋 table
Table with n (count) and arguments.

FrameworkZ.Utilities:PrintTable(tbl)

method
Print a table to console using DumpTable.

Parameters

tbl 📋 table
The table to print.

FrameworkZ.Utilities:RemoveContextDuplicates(worldObjects)

method
Remove duplicate world objects from context menu.

Parameters

worldObjects 📋 table
Array of world objects.

Returns

📋 table
Array without duplicates.

FrameworkZ.Utilities:TableContainsKey(t, key)

method
Check if a table contains a specific key.

Parameters

t 📋 table
The table to search.
key 🏷️ mixed
The key to find.

Returns

✅ boolean
True if the key exists.

FrameworkZ.Utilities:TableContainsValue(t, value)

method
Check if a table contains a specific value.

Parameters

t 📋 table
The table to search.
value 🏷️ mixed
The value to find.

Returns

✅ boolean
True if the value exists.

FrameworkZ.Utilities:TableIsEmpty(t)

method
Check if a table is empty.

Parameters

t 📋 table
The table to check.

Returns

✅ boolean
True if empty or not a table.

FrameworkZ.Utilities:TrimString(str, maxLength, addEllipsis)

method
Trims a string to a maximum length, optionally adding ellipsis.

Parameters

str 📝 string
The string to trim.
maxLength 🏷️ int
The maximum allowed length.
addEllipsis ✅ boolean
(Optional) If true, appends "..." if trimmed.

Returns

📝 string
The trimmed string.

FrameworkZ.Utilities:Unpack(t)

method
Unpack a packed table back to individual arguments.

Parameters

t 📋 table
The packed table with n count.

Returns

🏷️ vararg
The unpacked arguments.

FrameworkZ.Utilities:WordWrapText(text, maxLength, eolDelimiter)

method
Word wraps text to a specified length.

Parameters

text 📝 string
The text to word wrap.
maxLength 🏷️ int
The maximum length of a line (default: 28).
eolDelimiter 📝 string
(Optional) The end of line delimiter. Returns a \table of lines if not supplied.

Returns

🏷️ mixed
The word wrapped text as a \string or a \table of lines of text if no eolDelimiter was supplied as an argument.