2020-12-30 21:45:08 +00:00
|
|
|
<Mods LoadCommand = "%xero(function(self)
|
|
|
|
--[[
|
|
|
|
|
|
|
|
+ - tested, implemented, works fine
|
|
|
|
/ - implemented, but not tested
|
|
|
|
- - not implemented, not tested
|
2020-12-30 22:48:36 +00:00
|
|
|
? - needs more testing
|
2020-12-30 21:45:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- c2l
|
|
|
|
|
|
|
|
+c2l(start, ending, trunc) -- makes a chart2lua of a segment and uses that
|
|
|
|
-- start: start beat
|
|
|
|
-- ending: ending beat
|
|
|
|
-- trunc: whether to include the notes at beat (ending)
|
|
|
|
|
2021-01-01 08:03:42 +00:00
|
|
|
/c2l(notedata) -- uses an existing chart2lua
|
2020-12-30 21:45:08 +00:00
|
|
|
-- notedata: notitg format notedata, like the automatically generated notedata from 'save area to lua'
|
|
|
|
|
|
|
|
|
|
|
|
-- beat
|
|
|
|
|
2021-01-01 08:03:42 +00:00
|
|
|
+beat(table) -- raw beat input
|
2020-12-30 21:45:08 +00:00
|
|
|
-- table: beat table of every beat to fire on
|
|
|
|
|
|
|
|
|
|
|
|
-- forl
|
|
|
|
|
|
|
|
+forl(start, ending, add) -- acts as a for loop
|
|
|
|
-- start, ending and add act like arguments to a for loop
|
|
|
|
|
|
|
|
|
|
|
|
-- ways to interact with a beatobj
|
|
|
|
|
|
|
|
+beatobj:wiggle([perc], mod) -- wiggles a mod back and forth
|
|
|
|
-beatobj:sharpwiggle([perc], mod) -- wiggle(), but the ease is aligned with the start
|
|
|
|
+beatobj:bounce([perc], mod) -- bounces a mod up and down
|
|
|
|
+beatobj:onoff([perc], mod) -- turns a mod on and off
|
|
|
|
+ beatobj:wiggle0([perc], mod)
|
|
|
|
-beatobj:sharponoff([perc], mod) -- onoff(), but the ease is aligned with the start
|
|
|
|
- beatobj:sharpwiggle0([perc], mod)
|
2020-12-30 23:08:31 +00:00
|
|
|
+beatobj:kick([perc], mod) -- does a createReverse() version of the mod, for making kicks
|
|
|
|
+ beatobj:reverse([perc], mod)
|
|
|
|
+beatobk:velocitymap([perc], mod) -- kick(), but without aligning the ease at 0
|
|
|
|
+beatobk:velocitymapwiggle([perc], mod) -- velocitymap(), but it inverts each time
|
|
|
|
/beatobj:temp([perc], mod) -- does a createTemp() version of the mod
|
2020-12-30 22:48:36 +00:00
|
|
|
+beatobj:addm([perc], mod) -- adds a mod value every beat, useful for offsets
|
2020-12-30 21:45:08 +00:00
|
|
|
-- perc: mod percentage, defaults to 100
|
|
|
|
-- mod: mod name
|
|
|
|
|
2020-12-30 22:48:36 +00:00
|
|
|
+beatobj:f(function(beat, i, off, len) end) -- for custom mods, runs a function for each beat
|
2020-12-30 21:45:08 +00:00
|
|
|
-- beat: guess
|
|
|
|
-- i: index of beat
|
|
|
|
-- off: offset, is equal to i%2*2-1
|
|
|
|
-- len: length until next beat
|
|
|
|
|
2020-12-30 22:48:36 +00:00
|
|
|
+beatobj:ease(ease) -- sets an ease function for trailing functions to use
|
2020-12-30 21:45:08 +00:00
|
|
|
-- ease: ease function
|
2020-12-30 22:48:36 +00:00
|
|
|
+beatobj:align(a) -- aligns all ease functions with the snapping/fastest point at a
|
2020-12-30 21:45:08 +00:00
|
|
|
-- a: snapping point
|
|
|
|
|
2020-12-30 22:48:36 +00:00
|
|
|
+beatobj:mixease(ease1, ease2, a) -- does :ease(mixEase(ease1, ease2, a)) and :align(a)
|
2020-12-30 21:45:08 +00:00
|
|
|
-- ease1: in easing function
|
|
|
|
-- ease2: out easing function
|
|
|
|
-- a: snapping point
|
|
|
|
|
2020-12-30 22:48:36 +00:00
|
|
|
+beatobj:setl(a) -- sets a to the length of each ease
|
2020-12-30 21:45:08 +00:00
|
|
|
-- a: length
|
|
|
|
|
|
|
|
+beatobj:add(beatobj) -- merges another beatobj table
|
|
|
|
-- beatobj: the merged beatobj
|
|
|
|
|
2020-12-30 22:48:36 +00:00
|
|
|
+beatobj:clone(beat) -- clones the beat timings from the first beat onward to the beat
|
2020-12-30 21:45:08 +00:00
|
|
|
-- beat: the beat to copy the rhythm to
|
|
|
|
|
2021-01-01 08:03:42 +00:00
|
|
|
-beatobj:forclone(start, ending, add) -- clone(), but as a for loop
|
2020-12-30 21:45:08 +00:00
|
|
|
-- start, ending and add act like arguments to a for loop
|
|
|
|
|
2020-12-30 22:48:36 +00:00
|
|
|
+beatobj:filter(filterfunc) -- filters the beatobj with a filter function, return true to keep the element and false to discard it
|
2020-12-30 21:45:08 +00:00
|
|
|
-- filterfunc(value, index): the filter function
|
|
|
|
|
2020-12-30 22:48:36 +00:00
|
|
|
+beatobj:filtermines() -- remove all mines from the c2l
|
|
|
|
|
|
|
|
?beatobj:merge() -- merge beats that are on the same beat and column
|
|
|
|
+beatobj:aggressivemerge() -- merge beats that are on the same beat
|
2020-12-30 21:45:08 +00:00
|
|
|
]]
|
|
|
|
|
|
|
|
local function copyTable(datatable)
|
|
|
|
local tblRes = {}
|
|
|
|
if type(datatable) == 'table' then
|
|
|
|
for k,v in pairs(datatable) do tblRes[k]=copyTable(v) end
|
|
|
|
else
|
|
|
|
tblRes=datatable
|
|
|
|
end
|
|
|
|
return tblRes
|
|
|
|
end
|
|
|
|
|
|
|
|
local function mixEase(e1, e2, point)
|
2020-12-30 22:49:47 +00:00
|
|
|
if not point then point = 0.5 end
|
|
|
|
|
|
|
|
return function(a)
|
|
|
|
if a < point then
|
|
|
|
return e1(a / point) * point
|
|
|
|
else
|
|
|
|
return e2((a - point) / (1 - point)) * (1 - point) + point
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-12-30 21:45:08 +00:00
|
|
|
|
|
|
|
local beatobjTemplate = {
|
|
|
|
_beats = {},
|
|
|
|
_ease = inOutCirc,
|
|
|
|
_align = 0.5,
|
|
|
|
_length = 1,
|
|
|
|
|
|
|
|
-- setters
|
|
|
|
setl = function(self, a) self._length = a; return self end,
|
|
|
|
ease = function(self, a) self._ease = a; return self end,
|
|
|
|
align = function(self, a) self._align = a; return self end,
|
|
|
|
|
|
|
|
-- almost setters but not quite
|
|
|
|
add = function(self, add)
|
|
|
|
for i,b in ipairs(add._beats) do
|
|
|
|
table.insert(self._beats, b)
|
|
|
|
end
|
|
|
|
return self
|
|
|
|
end,
|
|
|
|
mixease = function(self, e1, e2, a)
|
|
|
|
self._ease = mixEase(e1, e2, a)
|
|
|
|
self._align = a
|
2020-12-30 22:48:36 +00:00
|
|
|
return self
|
2020-12-30 21:45:08 +00:00
|
|
|
end,
|
|
|
|
|
|
|
|
-- meta / manipulators
|
|
|
|
filter = function(self, filterfunc)
|
|
|
|
local beats = {}
|
|
|
|
for i,v in ipairs(self._beats) do
|
|
|
|
local check = filterfunc(v, i)
|
|
|
|
if check then table.insert(beats, v) end
|
|
|
|
end
|
|
|
|
self._beats = beats
|
|
|
|
return self
|
|
|
|
end,
|
|
|
|
filtermines = function(self)
|
2020-12-30 22:48:36 +00:00
|
|
|
self = self:filter(function(v) return v[3] ~= 'M' end)
|
2020-12-30 21:45:08 +00:00
|
|
|
return self
|
|
|
|
end,
|
|
|
|
f = function(self, forfunc)
|
|
|
|
for i,v in ipairs(self._beats) do
|
|
|
|
-- function(beat, i, off, len)
|
|
|
|
forfunc(v[1], i, i%2*2-1, (self._beats[i + 1] or {v[1] + self._length})[1] - v[1])
|
|
|
|
end
|
|
|
|
|
|
|
|
return self
|
|
|
|
end,
|
|
|
|
clone = function(self, beat)
|
2020-12-30 22:48:36 +00:00
|
|
|
local newbeats = copyTable(self._beats)
|
2020-12-30 21:45:08 +00:00
|
|
|
for i,v in ipairs(self._beats) do
|
|
|
|
local newv = {}
|
|
|
|
newv[1] = v[1] - self._beats[1][1] + beat
|
|
|
|
table.insert(newbeats, newv)
|
|
|
|
end
|
|
|
|
|
|
|
|
self._beats = newbeats
|
|
|
|
return self
|
|
|
|
end,
|
2020-12-30 22:48:36 +00:00
|
|
|
merge = function(self)
|
|
|
|
local seen = {}
|
|
|
|
local merged = {}
|
|
|
|
for _,v in ipairs(self._beats) do
|
|
|
|
local doMerge = true
|
|
|
|
for _,s in ipairs(seen) do
|
|
|
|
if v[1] == s[1] and ((v[2] == nil or s[2] == nil) or v[2] == s[2]) then
|
|
|
|
doMerge = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if doMerge then table.insert(merged, v) end
|
|
|
|
table.insert(seen, {v[1], v[2]})
|
|
|
|
end
|
|
|
|
|
|
|
|
self._beats = merged
|
|
|
|
return self
|
|
|
|
end,
|
|
|
|
aggressivemerge = function(self)
|
|
|
|
local seen = {}
|
|
|
|
local merged = {}
|
|
|
|
for _,v in ipairs(self._beats) do
|
|
|
|
local doMerge = true
|
|
|
|
for _,s in ipairs(seen) do
|
|
|
|
if v[1] == s[1] then
|
|
|
|
doMerge = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if doMerge then table.insert(merged, v) end
|
|
|
|
table.insert(seen, {v[1], v[2]})
|
|
|
|
end
|
|
|
|
|
|
|
|
self._beats = merged
|
|
|
|
return self
|
|
|
|
end,
|
2020-12-30 21:45:08 +00:00
|
|
|
|
|
|
|
-- mods
|
|
|
|
wiggle = function(self, perc, mod)
|
|
|
|
if mod == nil then mod = perc; perc = 100 end
|
|
|
|
|
|
|
|
for i,v in ipairs(self._beats) do
|
|
|
|
local len = self._length
|
|
|
|
local off = i%2*2-1
|
|
|
|
ease {v[1] - len / (1 / self._align), len, self._ease, perc * off, mod}
|
|
|
|
end
|
|
|
|
|
|
|
|
return self
|
|
|
|
end,
|
|
|
|
onoff = function(self, perc, mod)
|
|
|
|
if mod == nil then mod = perc; perc = 100 end
|
|
|
|
|
|
|
|
for i,v in ipairs(self._beats) do
|
|
|
|
local len = self._length
|
|
|
|
local off = i%2
|
|
|
|
ease {v[1] - len / (1 / self._align), len, self._ease, perc * off, mod}
|
|
|
|
end
|
|
|
|
|
|
|
|
return self
|
|
|
|
end,
|
|
|
|
|
|
|
|
addm = function(self, perc, mod)
|
|
|
|
if mod == nil then mod = perc; perc = 100 end
|
|
|
|
|
|
|
|
for i,v in ipairs(self._beats) do
|
|
|
|
local len = self._length
|
|
|
|
add {v[1] - len / (1 / self._align), len, self._ease, perc, mod}
|
|
|
|
end
|
|
|
|
|
|
|
|
return self
|
2020-12-30 22:48:36 +00:00
|
|
|
end,
|
2020-12-30 21:45:08 +00:00
|
|
|
|
|
|
|
bounce = function(self, perc, mod)
|
|
|
|
if mod == nil then mod = perc; perc = 100 end
|
|
|
|
|
|
|
|
local function bounceease(a)
|
|
|
|
if a < 0.5 then
|
|
|
|
return (self._ease(a + 0.5) - 0.5) / 0.5
|
|
|
|
else
|
|
|
|
return 1 - (self._ease(a - 0.5) / 0.5)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for i,v in ipairs(self._beats) do
|
|
|
|
local len = self._length
|
|
|
|
|
|
|
|
ease {v[1], len, bounceease, perc, mod}
|
|
|
|
end
|
|
|
|
|
2020-12-30 23:08:31 +00:00
|
|
|
return self
|
|
|
|
end,
|
|
|
|
|
|
|
|
kick = function(self, perc, mod)
|
|
|
|
if mod == nil then mod = perc; perc = 100 end
|
|
|
|
|
|
|
|
local function out(a)
|
|
|
|
return 1 - ((self._ease(a * 0.5 + 0.5) - 0.5) / 0.5)
|
|
|
|
end
|
|
|
|
|
|
|
|
for _,v in ipairs(self._beats) do
|
|
|
|
local len = self._length
|
|
|
|
|
|
|
|
ease {v[1], len, out, perc, mod}
|
|
|
|
end
|
|
|
|
|
|
|
|
return self
|
|
|
|
end,
|
|
|
|
velocitymap = function(self, perc, mod)
|
|
|
|
if mod == nil then mod = perc; perc = 100 end
|
|
|
|
|
|
|
|
local function map(a)
|
|
|
|
if a < 0.5 then
|
|
|
|
return self._ease(a / 0.5)
|
|
|
|
else
|
|
|
|
return 1 - self._ease(a / 0.5 - 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for _,v in ipairs(self._beats) do
|
|
|
|
local len = self._length
|
|
|
|
|
|
|
|
ease {v[1] - len / (1 / self._align), len, map, perc, mod}
|
|
|
|
end
|
|
|
|
|
|
|
|
return self
|
|
|
|
end,
|
|
|
|
velocitymapwiggle = function(self, perc, mod)
|
|
|
|
if mod == nil then mod = perc; perc = 100 end
|
|
|
|
|
|
|
|
local function map(a)
|
|
|
|
if a < 0.5 then
|
|
|
|
return self._ease(a / 0.5)
|
|
|
|
else
|
|
|
|
return 1 - self._ease(a / 0.5 - 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for i,v in ipairs(self._beats) do
|
|
|
|
local len = self._length
|
|
|
|
local off = i%2*2-1
|
|
|
|
|
|
|
|
ease {v[1] - len / (1 / self._align), len, map, perc * off, mod}
|
|
|
|
end
|
|
|
|
|
|
|
|
return self
|
|
|
|
end,
|
|
|
|
|
|
|
|
temp = function(self, perc, mod)
|
|
|
|
if mod == nil then mod = perc; perc = 100 end
|
|
|
|
|
|
|
|
local function temp(a)
|
|
|
|
if a == 1 then return self._ease(0) end
|
|
|
|
return self._ease(a)
|
|
|
|
end
|
|
|
|
|
|
|
|
for i,v in ipairs(self._beats) do
|
|
|
|
local len = self._length
|
|
|
|
|
|
|
|
ease {v[1] - len / (1 / self._align), len, temp, perc, mod}
|
|
|
|
end
|
|
|
|
|
2020-12-30 21:45:08 +00:00
|
|
|
return self
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2020-12-30 22:48:36 +00:00
|
|
|
-- aliases
|
|
|
|
beatobjTemplate.wiggle0 = beatobjTemplate.onoff
|
2020-12-30 23:08:31 +00:00
|
|
|
beatobjTemplate.reverse = beatobjTemplate.kick
|
2020-12-30 22:48:36 +00:00
|
|
|
|
2020-12-30 21:45:08 +00:00
|
|
|
function c2l(start, ending, trunc)
|
|
|
|
local self = copyTable(beatobjTemplate)
|
2021-01-01 08:03:42 +00:00
|
|
|
if ending == nil then
|
|
|
|
self._beats = start
|
|
|
|
else
|
|
|
|
self._beats = P1:GetNoteData(start, ending)
|
|
|
|
end
|
2020-12-30 21:45:08 +00:00
|
|
|
return self
|
|
|
|
end
|
|
|
|
|
|
|
|
function forl(start, ending, add)
|
|
|
|
add = add or 1
|
|
|
|
local self = copyTable(beatobjTemplate)
|
|
|
|
|
|
|
|
local v = {}
|
|
|
|
for i = start, ending, add do
|
|
|
|
table.insert(v, {i})
|
|
|
|
end
|
|
|
|
|
|
|
|
self._beats = v
|
|
|
|
return self
|
|
|
|
end
|
2021-01-01 08:03:42 +00:00
|
|
|
|
|
|
|
function beat(tbl)
|
|
|
|
local self = copyTable(beatobjTemplate)
|
|
|
|
for _,b in ipairs(tbl) do
|
|
|
|
table.insert(self._beats, {b})
|
|
|
|
end
|
|
|
|
return self
|
|
|
|
end
|
2020-12-30 21:45:08 +00:00
|
|
|
end)"
|
|
|
|
Type = "ActorFrame"/>
|