2020-01-29 03:26:28 +00:00
|
|
|
--[[
|
2020-03-15 09:28:50 +00:00
|
|
|
batteries for lua
|
2020-01-29 03:26:28 +00:00
|
|
|
|
|
|
|
if required as the "entire library" (ie by this file), puts everything into
|
2020-03-15 09:28:50 +00:00
|
|
|
global namespace by default as it'll presumably be commonly used
|
2020-01-29 03:26:28 +00:00
|
|
|
|
2020-03-15 09:28:50 +00:00
|
|
|
if not, several of the modules work as normal lua modules and return a table
|
2020-01-29 03:26:28 +00:00
|
|
|
for local-friendly use
|
2020-03-15 09:28:50 +00:00
|
|
|
|
|
|
|
the others that modify some global table can be talked into behaving as normal
|
|
|
|
lua modules as well by setting appropriate globals prior to inclusion
|
|
|
|
|
|
|
|
you can avoid modifying any global namespace by setting
|
|
|
|
|
|
|
|
BATTERIES_NO_GLOBALS = true
|
|
|
|
|
|
|
|
before requiring, then everything can be accessed as eg
|
|
|
|
|
|
|
|
batteries.table.stable_sort
|
2020-01-29 03:26:28 +00:00
|
|
|
]]
|
|
|
|
|
|
|
|
local path = ...
|
2020-03-15 09:28:50 +00:00
|
|
|
local function require_relative(p)
|
|
|
|
return require(table.concat({path, p}, "."))
|
|
|
|
end
|
|
|
|
|
|
|
|
if BATTERIES_NO_GLOBALS then
|
|
|
|
--define local tables for everything to go into
|
|
|
|
BATTERIES_MATH_MODULE = {}
|
|
|
|
BATTERIES_TABLE_MODULE = {}
|
|
|
|
BATTERIES_FUNCTIONAL_MODULE = {}
|
2020-01-29 03:26:28 +00:00
|
|
|
end
|
|
|
|
|
2020-03-15 09:28:50 +00:00
|
|
|
local _class = require_relative("class")
|
2020-01-29 03:26:28 +00:00
|
|
|
|
2020-03-15 09:28:50 +00:00
|
|
|
local _math = require_relative("math")
|
2020-01-29 03:26:28 +00:00
|
|
|
|
2020-03-15 09:28:50 +00:00
|
|
|
local _table = require_relative("table")
|
|
|
|
local _stable_sort = require_relative("stable_sort")
|
2020-01-29 03:26:28 +00:00
|
|
|
|
2020-03-15 09:28:50 +00:00
|
|
|
local _functional = require_relative("functional")
|
|
|
|
local _sequence = require_relative("sequence")
|
2020-01-29 03:26:28 +00:00
|
|
|
|
2020-03-15 09:28:50 +00:00
|
|
|
local _vec2 = require_relative("vec2")
|
|
|
|
local _vec3 = require_relative("vec3")
|
|
|
|
local _intersect = require_relative("intersect")
|
2020-01-29 03:26:28 +00:00
|
|
|
|
2020-03-15 09:28:50 +00:00
|
|
|
local _unique_mapping = require_relative("unique_mapping")
|
|
|
|
local _state_machine = require_relative("state_machine")
|
2020-01-31 00:56:37 +00:00
|
|
|
|
2020-03-15 09:28:50 +00:00
|
|
|
local _async = require_relative("async")
|
|
|
|
|
|
|
|
local _manual_gc = require_relative("manual_gc")
|
|
|
|
|
|
|
|
local _colour = require_relative("colour")
|
|
|
|
|
|
|
|
--export globally if required
|
|
|
|
if not BATTERIES_NO_GLOBALS then
|
|
|
|
class = _class
|
|
|
|
sequence = _sequence
|
|
|
|
|
|
|
|
vec2 = _vec2
|
|
|
|
vec3 = _vec3
|
|
|
|
intersect = _intersect
|
|
|
|
|
|
|
|
unique_mapping = _unique_mapping
|
|
|
|
state_machine = _state_machine
|
|
|
|
async = _async
|
|
|
|
manual_gc = _manual_gc
|
|
|
|
|
|
|
|
--support both spellings
|
|
|
|
colour = _colour
|
|
|
|
color = _colour
|
|
|
|
end
|
2020-02-01 08:30:36 +00:00
|
|
|
|
2020-03-15 09:28:50 +00:00
|
|
|
--either way, export to package registry
|
|
|
|
return {
|
|
|
|
class = _class,
|
|
|
|
math = _math,
|
|
|
|
table = _table,
|
|
|
|
stable_sort = _stable_sort,
|
|
|
|
functional = _functional,
|
|
|
|
sequence = _sequence,
|
|
|
|
vec2 = _vec2,
|
|
|
|
vec3 = _vec3,
|
|
|
|
intersect = _intersect,
|
|
|
|
unique_mapping = _unique_mapping,
|
|
|
|
state_machine = _state_machine,
|
|
|
|
async = _async,
|
|
|
|
manual_gc = _manual_gc,
|
|
|
|
colour = _colour,
|
2020-03-15 10:38:19 +00:00
|
|
|
color = _colour,
|
2020-03-15 09:28:50 +00:00
|
|
|
}
|