Skip to content

Built in functions

DPS2004 edited this page May 27, 2022 · 8 revisions

The functions on this page are available without loading any extensions. They provide a base that most extensions build off of.

level:offset(beat)

Changes the global event offset by beat beats.

Example:

level:comment(4, 'oh wow') -- Places a comment on beat 4. :comment is available in the core extension.

level:offset(2) -- Changes the global event offset to 2. All events from this point on will be placed 2 beats later.

level:comment(6, 'haha') -- Places a comment on beat 8.

level:offset(-4) -- The beat parameter can be negative. It causes the beats to be placed earlier.

level:comment(16, 'awesome') -- Places a comment on beat 12.

level:getbm(beat)

Returns two numbers, beat and measure. This is calculated using existing SetCrotchetsPerBar events, and is one-indexed.

Example:

image
-- This example assumes that level.rdlevel contains the events seen above.

print(level:getbm(0)) --  Prints "1, 1" in the console when main.lua is run.

print(level:getbm(7)) --  Prints "1, 8"

print(level:getbm(8)) --  Prints "2, 1"

print(level:getbm(12)) -- Prints "3, 1"

print(level:getbm(13)) -- Prints "3, 2"
Clone this wiki locally