utility.lua
Classes and functions defined:
- array_join function - if the input is not an array it will be converted to a string and
- bitOr function - this is a pseudo bitwise OR operation assumes value2 is always a power of 2 (limits carry errors in the addition) mimics the logic of hasBit with the addition if bit not set
- canOpenDirectory function - param path (string) The path to check.
- compare_tables function - Compare values of two simple (non-nested) tables
- flag_clear function - Clear flag in flags and return new flags (unchanged if flag was already cleared).
- flag_isset function - Helper functions for flags NB: flag must be a SINGLE flag, i.e. a power of two: 1, 2, 4, 8, ... Check if flag is set in flags
- flag_set function - Set flag in flags and return new flags (unchanged if flag was already set).
- flag_toggle function - Toggle flag in flags, i.e. set if currently cleared, clear if currently set.
- getRandomEntryFromArray function - Get a random item from an array.
- hasBit function - Check bit is set
- inspect function - Simplified interface for serializing a value with option for depth See serialize for further explanation Output is dumped to the console
- isDirectory function - param path (string) The path to check.
- isTableEmpty function - Check whether the table is empty.
- list_to_set function - Convert a list to a set
- loadfile_envcall function - Variation on loadfile() which allows for the loaded file to have global references resolved in supplied tables. On failure, returns nil and an error. On success, returns the file as a function just like loadfile() does with the difference that the first argument to this function should be a table in which globals are looked up and written to. Note: Unlike normal loadfile, this version also accepts files which start with the UTF-8 byte order marker
- loadstring_envcall function
- loadstring_envcall function
- noop function
- openURL function - Open a URL shown in game in the OS's web browser, tailored to each OS variant
- pause_gc_and_use_weak_keys function - Note that the function is run as a pcall, so any error will be caught and
- rangeMapLookup function - Find the smallest bucket with its upper value less or equal to a given number,
- serialize function - Serialize a value. Call it with the value to serialize and print the output. By default it will end recursion when a cycle is detected.
- serialize_string function
- serialize_table function
- shallow_clone function - Clones a table, but only the first level.
- stripTrailingSlashes function - Strip trailing slashes from a path.
- table_contains function - Checks if the table contains item
- table_merge function - Merge tables in one table
- values function - Iterator factory for iterating over the deep children of a table. For example: for fn in values(_G, "*.remove") do fn() end Will call os.remove() and table.remove() There can be multiple wildcards (asterisks). --