Factorio Library


A set of high-quality, commonly-used utilities for creating Factorio mods.

Internal
21 days ago
0.18 - 1.1
717K

Changelog

Version: 0.14.0
Date: 2024-03-29
  Features:
    - Added `gui-lite.format_handlers` function.
    - Added `gui-templates` module for building various common and/or annoying GUI components. Currently just makes technology slots.
    - Added `table.binary_search` function.
    - Added `technology` module with various runtime technology-related utilities.
    - Added technology slot styles.
    - Added require guards to allow requiring flib modules with any syntax without breaking upvalues.
  Changes:
    - `data_util.create_icons` no longer defines default icon size or scale. (#64)
  Bugfixes:
    - Fixed `data_util.get_energy_value` not accepting capital `K` as a unit suffix. (#59)
    - Fixed that dictionary-lite translation batches would not always be re-requested in their entirety due to undefined Lua next() behavior.
Version: 0.13.0
Date: 2023-10-14
  Features:
    - [position] Added `position.ge`, `position.gt`, and `position.lerp` functions.
  Bugfixes:
    - [bounding-box] Fixed `bounding_box.recenter_on()` not properly preserving box dimensions.
Version: 0.12.9
Date: 2023-06-01
  Bugfixes:
    - Fixed Chinese translation making the mod unloadable (#53)
Version: 0.12.8
Date: 2023-05-29
  Bugfixes:
    - [dictionary-lite] Fixed that the total strings count did not include "initial_contents" strings
Version: 0.12.7
Date: 2023-04-30
  Features:
    - Added `flib_nav_(backward|forward)_(black|white|disabled)` sprites
    - Added `flib_titlebar_separator_line` and `flib_titlebar_search_textfield` styles
  Changes:
    - Updated base dependency to 1.1.80
Version: 0.12.6
Date: 2023-03-20
  Bugfixes:
    - [gui-lite] Fixed that drag_target was not restored to GUI elem definitions after being used in gui.add
Version: 0.12.5
Date: 2023-03-09
  Features:
    - `dictionary-lite` and `gui-lite` modules are now compatible with the core `event_handler`
  Bugfixes:
    - [bounding-box] Fixed `bounding_box.from_dimensions()` returning a 0x0 area at left_top (#49)
    - Fixed `selected` button styles having an extra vertical offset when clicked
Version: 0.12.4
Date: 2022-12-30
  Changes:
    - flib_selected_frame_action_button and flib_selected_tool_button styles now have a vertical offset
    - Improved slot style coloring to be more consistent
    - Updated table module to use more generics for callback return values
  Bugfixes:
    - Fixed missing clicked graphical sets on slot styles
    - Fixed missing return types in table module callback functions
    - Fixed that long mod names would cut off in the dictionary-lite progress window
Version: 0.12.3
Date: 2022-12-14
  Bugfixes:
    - Fixed a crash when calling `bounding_box.rotate()`
    - The base mod dependency is no longer optional - it was causing the game to download flib versions that it could not run
Version: 0.12.2
Date: 2022-12-06
  Changes:
    - [queue] If the queue is empty, returns nil instead of throwing an error
    - [queue] Renamed functions to be much more clear, updated types to use generics
    - Updated types to work with recent FMTK releases
  Bugfixes:
    - [dictionary-lite] Fixed an occasional crash related to Lua memory management internals
Version: 0.12.1
Date: 2022-12-06
  Bugfixes:
    - [dictionary-lite] Fixed a crash when re-requesting a missed translation batch
Version: 0.12.0
Date: 2022-12-06
  Features:
    - Added 'bounding-box' module
      - A cleaned up version of the 'area' module that treats bounding boxes as immutable and does not use metatables
      - Since the cleanup was a breaking change, a new module was created
    - Added 'dictionary-lite' module
      - Takes advantage of new Factorio API features to drastically simplify the process
      - Increases translation speed in singleplayer by a factor of 10
    - Added 'format' module with various string formatting functions
    - Added 'gui-lite' module
      - Removes redundant features, simplifies the building process, and enhances type-checking and autocomplete
    - Added 'migration.handle_on_configuration_changed()'
    - Added 'position' module with various position manipulation functions
  Changes:
    - Changed preferred require syntax to '/' instead of '.'
    - Deprecated 'area' module in favor of the 'bounding-box' module
    - Deprecated 'dictionary' module in favor of the 'dictionary-lite' module
    - Deprecated 'event' module - type checking did not work and it didn't provide much over using 'script' directly
    - Deprecated 'gui' module in favor of the 'gui-lite' module
    - Deprecated 'misc' module in favor of the 'format' and 'position' modules
    - Removed 'queue.load()' and queue metatables
    - Updated type definitions to use generics where possible
  Bugfixes:
    - [dictionary] Fixed translations getting stuck on Factorio 1.1.73+
Version: 0.11.2
Date: 2022-09-18
  Bugfixes:
    - [dictionary] Fixed a crash when a player left the game under certain circumstances
Version: 0.11.1
Date: 2022-09-12
  Changes:
    - [dictionary] Added tooltip to GUI header explaining what it is
  Bugfixes:
    - [dictionary] Fixed that translations would stop being requested under certain circumstances
Version: 0.11.0
Date: 2022-09-04
  Features:
    - [area] Added `area.square()` to turn the area into a square
    - [area] Added `starting_offset` argument to `area.iterate()`
    - [dictionary] Added a GUI that shows translation progress
    - [math] Added `floored` and `ceiled` for flooring and ceiling to N decimal places.
    - [math] Added `sign` to return the signedness of a number as a multiplier
    - [math] Added `sum`, `maximum`, `minimum`, `midrange`, `range` for sets of numbers
  Changes:
    - [math] Deprecated `round_to`, `ceil_to`, `floor_to`
    - [math] `clamp` defaults to clamping between 0, 1 when min or max are not set
    - [dictionary] Removed string nesting to significantly reduce network traffic
      - This makes translation take significantly longer
  Bugfixes:
    - Fixed missing annotations in math and table libraries
    - [dictionary] Fixed that an empty translation would cause the translation after it to be skipped
    - [migration] Fixed a crash when loading the tutorial scenario
Version: 0.10.1
Date: 2022-02-24
  Bugfixes:
    - [event] Fixed a crash when passing `nil` to `event.on_nth_tick`
Version: 0.10.0
Date: 2022-02-24
  Features:
    - [direction] Added `direction.from_positions()`
    - [table] Added `table.get_or_insert()`
  Changes:
    - Converted from LDoc to EmmyLua annotations, enabling language server intellisense, but removing the docs website
      - A new website or other solution for online docs will be added someday. For now, in-line documentation was decided to be more beneficial.
    - [area] All constructor functions will automatically call `area.load()` to add the metatable
    - [area] All functions will ensure that any passed areas have `left_top` and `right_bottom` keys, and will automatically convert ones that do not
    - [migration] `migration.on_config_changed()` version migrations table is now optional
Version: 0.9.2
Date: 2021-11-18
  Bugfixes:
    - Fixed the dictionary module not separating dictionaries from separate mods properly
Version: 0.9.1
Date: 2021-11-16
  Bugfixes:
    - Fixed a crash when calling dictionary.load() before dictionary.init() has been able to fire
    - Fixed table.slice() and table.splice() stop-n-from-end being one position off
Version: 0.9.0
Date: 2021-11-11
  Features:
    - Added `queue` module
    - Added `table.array_merge()` and `table.retrieve()`
    - Added `flib_pin` and `flib_settings` sprites in black, white, and disabled variants
      - These are for use with frame action buttons
    - Added `gui.flib-keep-open` and `gui.flib-settings` locales for use with the aforementioned sprites
Version: 0.8.4
Date: 2021-09-19
  Features:
    - Added `flib-dictionary-levels-per-batch` setting
  Changes:
    - Children may now be defined in `gui.add()`
      - If you need to return refs to children, use `gui.build()` instead
    - `flib-translations-per-tick` setting is now hidden
Version: 0.8.3
Date: 2021-08-20
  Bugfixes:
    - Fixed that math.round() was incorrect for some negative numbers
    - Fixed that the on-tick-n module was not documented and not mentioned in the v0.8.0 changelog
Version: 0.8.2
Date: 2021-08-10
  Bugfixes:
    - Fixed the dictionary module not handling if the language detection string was lost across save/load
Version: 0.8.1
Date: 2021-08-09
  Changes:
    - The dictionary module no longer provides an event to hook, instead returning the finished dictionaries directly from `process_translation`
      - This is to allow a single-source-of-truth for the language's dictionaries, which was the original intention, but returning them in an event broke that intention
Version: 0.8.0
Date: 2021-08-08
  Features:
    - Added `area.from_shorthand` and `area.to_shorthand`
    - Added `dictionary` module, which is a fast and easy-to-use dictionary system for localised string translations
    - Added `flib_widthless_textfield` style
    - Added `gui.add`, `gui.set_action`, and `gui.get_action`
    - Added `on-tick-n` module, which allows you to schedule tasks to be executed on a specific tick
    - Added support for tags and actions in `gui.update`
    - Children in a `GuiBuildStructure` or `GuiUpdateStructure` can now be defined in the array portion, instead of in a `children` or `tabs` table
      - The subtables are still accepted for situations where they are appropriate (i.e. dynamically generated children)
    - `misc.delineate_number()` now supports decimal numbers
  Changes:
    - `area.load` will now automatically convert from a shorthanded area to a proper area if needed
    - Deprecated the old `gui` module and replaced it with the contents of `gui-beta`
      - Mods can still require `gui-beta`, but it will simply redirect to `gui` instead
      - Mods that depended on the old GUI module will need to update to the new one or download a copy of it to their mod - it is no longer supported whatsoever
    - Deprecated the `translation` module, replaced by the new `dictionary` module
      - The `translation` module still exists and can be used, but is no longer documented and its use is recommended against
  Bugfixes:
    - Fixed a crash when calling `gui.read_action()` when the element was invalid
    - Fixed `area.from_position` not actually creating a 1x1 area
Version: 0.7.0
Date: 2021-02-12
  Features:
    - Added `area` module
    - Added `flib_titlebar_flow` style
    - Added `divisor` argument to `math.round()`, allowing rounding to the nearest multiple of N
    - Added `math.max_double` and `math.min_double`
    - Added argument to `misc.ticks_to_timestring` to preserve leading zeroes
  Optimizations:
    - Significant performance improvements to `gui-beta.build()`
  Bugfixes:
    - Fixed `math.max_uint` being one number too large
    - Fixed `data-util.create_icons()` not using all of the icon specifications
Version: 0.6.1
Date: 2021-01-02
  Features:
    - Added proper documentation for the `gui-beta` module
Version: 0.6.0
Date: 2020-11-23
  Features:
    - Added WIP `gui-beta` module
      - This module is experimental, but is currently relatively stable. Use at your own risk. See the source code for documentation.
    - Additional arguments may be passed to `migration.on_config_changed()` to be available in the migration functions
    - Added `data-util.dark_red_button_tileset`
    - Added `flib_tool_button_dark_red` button style
  Changes:
    - Updated to Factorio 1.1
    - Modified `flib_selected_frame_action_button` style to better match the vanilla buttons
    - Made `new_layers` argument to `data-util.create_icons()` optional
    - Removed deprecated require paths for `data-util` and `reverse-defines` modules
Version: 0.5.0
Date: 2020-10-22
  Features:
    - Added indicator sprites
    - Added `flib_indicator` image style
  Changes:
    - Updated thumbnail
    - Changed `table.reduce()` to work with non-arrays
    - Changed `misc.ticks_to_timestring()` to use `game.ticks_played` by default, instead of `game.tick`
  Bugfixes:
    - Fixed a crash with serialise_localised_string (credit to dbeckwith)
Version: 0.4.1
Date: 2020-09-22
  Features:
    - Added a third return value to `table.for_n_of` signifying whether or not the end of the table was reached
    - Added a third return value to the callback of `table.for_n_of`, which is a flag requesting an immediate iteration abort
    - Added `flib_tool_button_light_green` button style
  Changes:
    - `table.for_n_of` now checks against the first (key) return of `next()` rather than the second (value) return
      - This changes how custom `next()` functions will behave, and brings it into consistency with the rest of Lua
Version: 0.4.0
Date: 2020-09-13
  Features:
    - Added `direction.to_vector_2d`
    - Additional arguments passed to `migration.run` will be passed on to the version functions within the migrations table
    - Added `math` module
  Bugfixes:
    - Fixed that using `gui.init()` to reset all filters did not update lookup tables
Version: 0.3.3
Date: 2020-08-31
  Features:
    - Added a map setting to adjust translation speed (avoid multiplayer drops for those with slow internet speeds)
Version: 0.3.2
Date: 2020-08-30
  Features:
    - Added `table.array_copy()`
    - Added `table.partial_sort()` for sorting an array over multiple ticks
  Changes:
    - Passing a custom `next` function to `table.for_n_of()` will bypass the key existence check
Version: 0.3.1
Date: 2020-08-24
  Features:
    - Added event.register_on_entity_destroyed()
    - Added flib_naked_scroll_pane_no_padding GUI style
  Changes:
    - Updated to Factorio 1.0
    - Renamed data_util to data-util and reverse_defines to reverse-defines
      - The old paths will still work until v0.4.0, but will print deprecation warnings
    - Removed vertically_stretchable from the flib_naked_scroll_pane GUI style to fix zero-height issue in non-fixed-height containers
Version: 0.3.0
Date: 2020-08-11
  Features:
    - Added "grey" and "orange" colored slot button styles
    - Added two new scroll-pane GUI styles
    - Added "table" module for working with tables
  Changes:
    - translation.init() is now required to be run during on_configuration_changed, in addition to on_init
      - This is to prevent the module translating and returning strings for things that may not exist anymore
Version: 0.2.0
Date: 2020-07-26
  Features:
    - Added gui.check_filter_validity(), which is a new REQUIRED setup function for the GUI module
    - Added translation.is_translating(), which checks whether the given player is actively translating
    - Added translation.translating_players_count(), which returns the number of players that are actively translating
    - Added several button and empty-widget styles, see "styles.md" topic in docs
  Changes:
    - The base mod is now marked as optional, to allow compatibility with total overhaul mods
  Bugfixes:
    - Fixed a crash with the GUI module when a handler was removed between mod versions while being registered in global
    - Fixed that gui.remove_player_filters() would not update lookup tables
Version: 0.1.5
Date: 2020-06-30
  Changes:
    - Moved styles into prototypes/styles
  Bugfixes:
    - Fixed nonexistent sound file error by inheriting from parent #13
Version: 0.1.4
Date: 2020-06-18
  Bugfixes:
    - Fixed a crash with the translation module related to old code having incorrect variable names
Version: 0.1.3
Date: 2020-06-18
  Features:
    - Added a myriad of colored slot styles; see "slot-styles.md" topic in docs
Version: 0.1.2
Date: 2020-06-10
  Bugfixes:
    - get_energy_value didn't parse energy strings with no SI prefix or deka
Version: 0.1.1
Date: 2020-06-10
  Features:
    - get_energy_value supports exponents from 10^-24 to 10^24
  Bugfixes:
    - get_energy_value returned string, string instead of nil when unable to parse exponent
Version: 0.1.0
Date: 2020-05-24
  Features:
    - Initial release