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.
Examples are in another repo.
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 basebatteries
directory - the one withinit.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")
Lua Core Extensions:
Extensions to existing lua core modules to provide missing features.
mathx
- Mathematical extensions. Aliasmath
.tablex
- Table handling extensions. Aliastable
.stringx
- String handling extensions. Aliasstring
.
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 dot:insert(i, v)
instead oftable.insert(t, i, v)
. Also supports method chaining for thefunctional
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 andipairs
-style iteration.sort
- Provides a stable merge+insertion sorting algorithm that is also, as a bonus, often faster thantable.sort
under luajit. Also exposesinsertion_sort
if needed. Aliasstable_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. Aliascolor
.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
- original license
- this fork's license (only applies to the files prefixed with the matching MIT LICENSE text, e.g logger.lua). Any file not prefixed with the specified text is under the original zlib license