Module helpers
Contains helper functions for common tasks.
Info:
- License: MIT
- Author: Nomad Monad
-
string_join (sep)
-
Return a function that joins a variable number of arguments, separated by the argument `sep` (default ', ').
Parameters:
Returns:
function
-
console_msg (arg)
-
Print to console and add new line separator.
Parameters:
-
print_func (sep)
-
Return a print function that joins the arguments with a separator.
Parameters:
- sep
string Default is ', '
Returns:
function
-
log_func (name, sep)
-
Return a log function that prepends the current date and a name to the arguments.
Parameters:
- name
string
- sep
string Default is ' --- '
Returns:
function
-
log_once_func (name, sep)
-
Return a log function that only logs each unique message once.
Useful for preventing console spam in loops or frequent function calls.
Parameters:
- name
string Logger name
- sep
string Default is ' --- '
Returns:
function Logger function that tracks logged messages
-
msg_box (msg, title, msgbox_type)
-
Show a Message Box dialogue
Parameters:
- msg
string
- title
number
- msgbox_type
number helpers.MsgBoxTypes
Returns:
number
See also:
-
iter (t)
-
Create an iterator function for a table.
https://www.lua.org/pil/7.1.html
Parameters:
Returns:
function
-
slice_table (source_table, start_idx, end_idx)
-
Slice a table.
Parameters:
- source_table
table
- start_idx
number
- end_idx
number
Returns:
table
-
file_exists (fpath)
-
Check if a file exists.
Parameters:
Returns:
boolean
-
read_file (fpath)
-
Read a file. Return the content as a string. If the file does not exist, throw an error.
Parameters:
Returns:
string
-
MsgBoxTypes
-
Constants for message box types.
Fields:
- OK
number
- OKCANCEL
number
- ABORTRETRYIGNORE
number
- YESNOCANCEL
number
- YESNO
number
- RETRYCANCEL
number