Adds some commonly used functions used in many modules
[[
| Common.auto_complete (options, input[, use_key=false][, rtn_key=false]) | Returns the closest match to the input |
| Common.clear_flying_text (surface) | Clears all flying text entites on a surface |
| Common.enum (tbl) | Converts a table to an enum |
| Common.ext_require (path, ...) | Calls a require and returns only the keys given, file must return a table |
| Common.extract_keys (tbl, ...) | Extracts certain keys from a table |
| Common.format_chat_colour (message, color) | Returns a message with valid chat tags to change its colour |
| Common.format_chat_colour_localized (message, color) | Returns a message with valid chat tags to change its colour, using localization |
| Common.format_chat_player_name (player[, raw_string=false]) | Returns the players name in the players color |
| Common.format_time (ticks, options) | Formats tick into a clean format, denominations from highest to lowest long will use words rather than letters time will use : separates string will return a string not a locale string when a denomination is false it will overflow into the next one |
| Common.move_items (items[, surface=navies][, position={0][, radius=32][, chest_type=iron-chest]) | Moves items to the position and stores them in the closest entity of the type given |
| Common.opt_require (path) | Calls a require that will not error if the file is not found |
| Common.param_check (value, test_type, param_name, param_number) | Raises an error when the value is the incorrect type, uses a consistent error message format |
| Common.player_return (value[, colour=defines.colour.white][, player=game.player]) | Will return a value of any type to the player/server console, allows colour for in-game players |
| Common.print_colored_grid_value (value, surface, position, offset, immutable, color_value, base_color, delta_color, under_bound, over_bound) | Prints a colored value on a location. |
| Common.print_grid_value (value, surface, position, scale, offset, immutable) | https://github.com/Refactorio/RedMew/blob/9184b2940f311d8c9c891e83429fc57ec7e0c4a2/map_gen/maps/diggy/debug.lua#L31 Prints a colored value on a location. |
| Common.string_contains (s, contains) | Tests if a string contains a given substring. |
| Common.table_alphanumsort (tbl) | Returns the list is a sorted way that would be expected by people (this is by key) |
| Common.table_keys (table[, sorted][, as_string]) | Returns a copy of all of the keys in the table. |
| Common.table_keysort (tbl) | Returns the list is a sorted way that would be expected by people (this is by key) (faster alterative than above) |
| Common.table_values (table[, sorted][, as_string]) | Returns a copy of all of the values in the table. |
| Common.type_check (value[, test_type=nil]) | Compare types faster for faster validation of params |
| Common.type_check_error (value, test_type, error_message, level) | Raises an error if the value is of the wrong type |
| Common.write_json (path, tbl) | Writes a table object to a file in json format |
Returns the closest match to the input
Parameters:Clears all flying text entites on a surface
Parameters:Converts a table to an enum
Parameters:Calls a require and returns only the keys given, file must return a table
Parameters:local extract, param_check = ext_require('expcore.common','extract','param_check')
Extracts certain keys from a table
Parameters:local key_three, key_one = extract({key_one='foo',key_two='bar',key_three=true},'key_three','key_one')
Returns a message with valid chat tags to change its colour
Parameters:Returns a message with valid chat tags to change its colour, using localization
Parameters:Returns the players name in the players color
Parameters:Formats tick into a clean format, denominations from highest to lowest long will use words rather than letters time will use : separates string will return a string not a locale string when a denomination is false it will overflow into the next one
Parameters:Moves items to the position and stores them in the closest entity of the type given
Parameters:Calls a require that will not error if the file is not found
Parameters:local file = opt_require('file.not.present') -- will not cause any error
Raises an error when the value is the incorrect type, uses a consistent error message format
Parameters:param_check('foo','number','repeat_count',2) -- will raise error "Invalid param #02 given to <anon>; repeat_count is not of type number"
Will return a value of any type to the player/server console, allows colour for in-game players
Parameters:player_return('Hello, World!') -- returns 'Hello, World!' to game.player or server console
player_return('Hello, World!','green') -- returns 'Hello, World!' to game.player with colour green or server console
player_return('Hello, World!',nil,player) -- returns 'Hello, World!' to the given player
Prints a colored value on a location.
When given a color_value and a delta_color, will change the color of the text from the base to base + value * delta. This will make the color of the text range from 'base_color' to 'base_color + delta_color' as the color_value ranges from 0 to 1
Parameters:https://github.com/Refactorio/RedMew/blob/9184b2940f311d8c9c891e83429fc57ec7e0c4a2/map_gen/maps/diggy/debug.lua#L31 Prints a colored value on a location.
Parameters:Tests if a string contains a given substring.
Parameters: Returns:Returns the list is a sorted way that would be expected by people (this is by key)
Parameters:Returns a copy of all of the keys in the table.
Parameters:Returns the list is a sorted way that would be expected by people (this is by key) (faster alterative than above)
Parameters:Returns a copy of all of the values in the table.
Parameters:Compare types faster for faster validation of params
Parameters:type_check('foo','string') -- return true
type_check('foo') -- return false
Raises an error if the value is of the wrong type
Parameters:type_check_error('foo','number','Value must be a number') -- will raise error "Value must be a number"