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
|
|
|
|
2020-05-02 09:59:02 +00:00
|
|
|
a collection of helpful code to get your project off the ground faster
|
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
|
|
|
|
|
|
|
|
local _class = require_relative("class")
|
2020-01-29 03:26:28 +00:00
|
|
|
|
2020-04-07 03:49:10 +00:00
|
|
|
local _mathx = require_relative("mathx")
|
2020-01-29 03:26:28 +00:00
|
|
|
|
2020-04-07 03:49:10 +00:00
|
|
|
local _tablex = require_relative("tablex")
|
2020-03-15 09:28:50 +00:00
|
|
|
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")
|
2020-05-02 09:59:02 +00:00
|
|
|
|
2020-03-15 09:28:50 +00:00
|
|
|
local _sequence = require_relative("sequence")
|
2020-05-02 09:59:02 +00:00
|
|
|
local _set = require_relative("set")
|
2020-01-29 03:26:28 +00:00
|
|
|
|
2020-04-17 00:35:00 +00:00
|
|
|
local _stringx = require_relative("stringx")
|
|
|
|
|
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")
|
|
|
|
|
2020-04-07 03:49:10 +00:00
|
|
|
--build the module
|
|
|
|
local _batteries = {
|
|
|
|
--fire and forget mode function
|
|
|
|
export = export,
|
|
|
|
--
|
|
|
|
class = _class,
|
|
|
|
--support x and non-x naming
|
|
|
|
math = _mathx,
|
|
|
|
mathx = _mathx,
|
|
|
|
--
|
|
|
|
table = _tablex,
|
|
|
|
tablex = _tablex,
|
2020-04-17 00:35:00 +00:00
|
|
|
--
|
|
|
|
string = _stringx,
|
|
|
|
stringx = _stringx,
|
2020-04-07 03:49:10 +00:00
|
|
|
--sorting routines
|
|
|
|
stable_sort = _stable_sort,
|
|
|
|
sort = _stable_sort,
|
|
|
|
--
|
|
|
|
functional = _functional,
|
2020-05-02 09:59:02 +00:00
|
|
|
--collections
|
2020-04-07 03:49:10 +00:00
|
|
|
sequence = _sequence,
|
2020-05-02 09:59:02 +00:00
|
|
|
set = _set,
|
2020-04-17 00:35:00 +00:00
|
|
|
--geom
|
2020-04-07 03:49:10 +00:00
|
|
|
vec2 = _vec2,
|
|
|
|
vec3 = _vec3,
|
|
|
|
intersect = _intersect,
|
|
|
|
--
|
|
|
|
unique_mapping = _unique_mapping,
|
|
|
|
state_machine = _state_machine,
|
|
|
|
async = _async,
|
|
|
|
manual_gc = _manual_gc,
|
|
|
|
colour = _colour,
|
|
|
|
color = _colour,
|
|
|
|
}
|
|
|
|
|
|
|
|
--easy export globally if required
|
|
|
|
function _batteries:export(self)
|
|
|
|
--export oo
|
2020-03-15 09:28:50 +00:00
|
|
|
class = _class
|
2020-04-07 03:49:10 +00:00
|
|
|
|
|
|
|
--overlay tablex and functional and sort routines onto table
|
|
|
|
_tablex.overlay(table, _tablex)
|
|
|
|
_tablex.overlay(table, _functional)
|
|
|
|
_stable_sort:export()
|
2020-03-15 09:28:50 +00:00
|
|
|
|
2020-04-07 03:49:10 +00:00
|
|
|
--functional module also available separate from table
|
|
|
|
functional = _functional
|
|
|
|
|
2020-05-02 09:59:02 +00:00
|
|
|
--export collections
|
2020-04-07 03:49:10 +00:00
|
|
|
sequence = _sequence
|
2020-05-02 09:59:02 +00:00
|
|
|
set = _set
|
2020-04-07 03:49:10 +00:00
|
|
|
|
|
|
|
--overlay onto math
|
|
|
|
_tablex.overlay(math, _mathx)
|
|
|
|
|
2020-04-17 00:35:00 +00:00
|
|
|
--overlay onto string
|
|
|
|
_tablex.overlay(string, _stringx)
|
|
|
|
|
2020-04-07 03:49:10 +00:00
|
|
|
--export geom
|
2020-03-15 09:28:50 +00:00
|
|
|
vec2 = _vec2
|
|
|
|
vec3 = _vec3
|
|
|
|
intersect = _intersect
|
|
|
|
|
2020-05-02 09:59:02 +00:00
|
|
|
--"misc" :)
|
2020-03-15 09:28:50 +00:00
|
|
|
unique_mapping = _unique_mapping
|
|
|
|
state_machine = _state_machine
|
|
|
|
async = _async
|
|
|
|
manual_gc = _manual_gc
|
|
|
|
|
|
|
|
--support both spellings
|
|
|
|
colour = _colour
|
|
|
|
color = _colour
|
2020-04-07 03:49:10 +00:00
|
|
|
|
|
|
|
--export top level module as well for ease of migration for code
|
|
|
|
batteries = _batteries
|
|
|
|
|
|
|
|
return self
|
2020-03-15 09:28:50 +00:00
|
|
|
end
|
2020-02-01 08:30:36 +00:00
|
|
|
|
2020-04-07 03:49:10 +00:00
|
|
|
return _batteries
|