Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Reusable dependencies for games made with lua (especially with love)

Notifications You must be signed in to change notification settings

wiredsoft-xyz/wired_batteries

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Batteries for Lua

Helpful stuff for making games with lua, especially with löve.

Get your projects off the ground faster! batteries provides implementations of many common algorithms and data structures useful for games.

Getting Started

How does that module work?

Examples are in another repo.

Installation

batteries works straight out of the repo with no separate build step. The license file required for use is included.

  • Put the files in their own directory (e.g lib/batteries), somewhere your project can access them.
  • require the base batteries directory - the one with init.lua in it.
  • With a normal require setup (ie stock LÖVE or lua), init.lua will pull in all the submodules.
local batteries = require("lib.batteries")

Module Overview

Lua Core Extensions:

Extensions to existing lua core modules to provide missing features.

  • mathx - Mathematical extensions. Alias math.
  • tablex - Table handling extensions. Alias table.
  • stringx - String handling extensions. Alias string.

General Utility:

General utility data structures and algorithms to speed you along your way.

  • class - OOP with inheritance and interfaces in a single function.
  • functional - Functional programming facilities. map, reduce, any, match, minmax, mean...
  • sequence - An oo wrapper on sequential tables, so you can do t:insert(i, v) instead of table.insert(t, i, v). Also supports method chaining for the functional interface above, which can save a lot of needless typing!
  • set - A set type supporting a full suite of set operations with fast membership testing and ipairs-style iteration.
  • sort - Provides a stable merge+insertion sorting algorithm that is also, as a bonus, often faster than table.sort under luajit. Also exposes insertion_sort if needed. Alias stable_sort.
  • state_machine - Finite state machine implementation with state transitions and all the rest. Useful for game states, AI, cutscenes...
  • timer - a "countdown" style timer with progress and completion callbacks.
  • pubsub - a self-contained publish/subscribe message bus. Immediate mode rather than queued, local rather than networked, but if you were expecting mqtt in 60 lines I don't know what to tell you. Scales pretty well nonetheless.
  • pretty - pretty printing tables for debug inspection.

Geometry:

Modules to help work with spatial concepts.

  • intersect - 2d intersection routines, a bit sparse at the moment.
  • vec2 - 2d vectors with method chaining, and garbage saving modifying operations. A bit of a mouthful at times, but you get used to it. (there's an issue discussing future solutions).
  • vec3 - 3d vectors as above.

Special Interest:

These modules are probably only useful to some folks in some circumstances, or are under-polished for one reason or another.

  • async - Asynchronous/"Background" task management.
  • colour - Colour conversion routines. Alias color.
  • manual_gc - Get GC out of your update/draw calls. Useful when trying to get accurate profiling information; moves "randomness" of GC. Requires you to think a bit about your garbage budgets though.
  • measure - Benchmarking helpers - measure the time or memory taken to run some code.
  • make_pooled - add pooling/recycling capability to a class

License

About

Reusable dependencies for games made with lua (especially with love)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%