Utils
Helper module for misc operations
Require
Section titled “Require”If the concord folder is in the root directory of your game, you can import this module like so:
Utils = require('concord.utils')Raises a formatted error.
Utils.error( level, str, ... )Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
level |
integer |
Error level passed to error(), plus one |
str |
string |
Format string |
... |
any |
Format arguments |
shallowCopy
Section titled “shallowCopy”Copies keys from orig into target. Existing keys in target are overwritten.
matches = Utils.shallowCopy( orig, target )Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
orig |
table |
Table to copy from |
target |
table |
Table to copy into |
Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
matches |
table |
target |
loadNamespace
Section titled “loadNamespace”Requires files and stores them in a namespace table.
Accepts a table of require paths: {“path/to/file_1”, “path/to/another/file_2”, “etc”} Accepts a path to a directory of Lua files: “my_files/here” Directory loading uses love.filesystem and requires LÖVE. If namespace is omitted, files are still required and this function returns nil.
Utils.loadNamespace( pathOrFiles, namespace )Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
pathOrFiles |
string|table |
A directory path or a table of require paths |
namespace |
table |
Table that will hold the required files |
Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
table|nil |
namespace The namespace table |