Creates a shallow copy of a table or directly returns non-table values.
exports.sonorancad.shallowcopy(data)
Parameter
Type
Description
orig
any
The value or table to copy. Can be of any type: table, string, number, etc.
Type
Description
any
If orig is a table: Returns a new table with the same key-value pairs as orig. If orig is not a table (e.g., a number, string, boolean): Returns the value directly.
-- Example 1: Shallow copying a tablelocal original = { a =1, b =2, c = { 3, 4 } }local copy = exports.sonorancad.shallowcopy(original)print(copy.a) -- Output: 1print(copy.b) -- Output: 2print(copy.c) -- Output: table: 0x... (same reference as original.c in shallow copy)-- Example 2: Copying a non-table valuelocal value =42local valueCopy = exports.sonorancad.shallowcopy(value)print(valueCopy) -- Output: 42
stringsplit
Splits a string into substrings based on a specified delimiter.
exports.sonorancad.stringsplit(inputstr, sep)
Parameter
Type
Description
inputstr
string
The input string that will be split into substrings based on a specified delimiter (sep)
sep
string
(Optional) If not provided, the default is "%s", which matches any whitespace character
Type
Description
table
The table contains the substrings of inputstr split by the delimiter sep. The substrings are stored sequentially starting at index 1
local result = exports.sonorancad.stringsplit("Hello,World,Lua", ",")-- result = { "Hello", "World", "Lua" }local result2 = exports.sonorancad.stringsplit("One Two Three")-- result2 = { "One", "Two", "Three" } (uses default separator: whitespace)
findIndex
Searches for a specific identifier in the LocationCache table and returns the index of the first matching entry.
exports.sonorancad.findIndex(identifier)
Parameter
Type
Description
identifier
any
The identifier to search for, compared against the apiId field of each entry in LocationCache.
Type
Description
number or nil
The index (i) of the first entry in LocationCache whose apiId matches identifier. nil if no matching entry is found
-- Example: Searching for an identifier in LocationCacheLocationCache = { { apiId =101, name ="LocationA" }, { apiId =202, name ="LocationB" }, { apiId =303, name ="LocationC" },}local index = exports.sonorancad.findIndex(202)print(index) -- Output: 2local notFound = exports.sonorancad.findIndex(404)print(notFound) -- Output: nil
GetIdentifiers
Extracts and organizes player identifiers into a key-value table format.
exports.sonorancad.GetIdentifiers(player)
Parameter
Type
Description
player
PlayerSource
The player source ID for whom the identifiers are being retrieved.
Type
Description
table
A key-value table where the keys are identifier types (e.g., steam, license, discord) and the values are the corresponding identifier strings.