-
Notifications
You must be signed in to change notification settings - Fork 1
Room related functions
The functions on this page are available by loading the room.lua extension. It is loaded by default.
Creates some helpful room events at beat beat
: a Move Room
event which moves the rooms to 50x 50y and scales them to 100%x 100%y and a Set Room Content Mode
event that makes the rooms stretch.
beat
can be omitted and they will be created at the start of the level.
Example:
level:setuprooms() -- it's that simple!
Returns the room at index index
(0-3 for regular rooms, 4 for the ontop room) in the form of an object with functions to modify values of it.
Example:
mycoolroom = level:getroom(0) -- Get the first room.
-- Now you can do stuff with it, such as
mycoolroom:movex(1, 75, 1, 'Linear')
-- to move it.
-- The function used above will be explained later.
Moves the room to x
% on the x axis at beat beat
with a duration duration
and ease ease
.
Example:
mycoolroom:movex(4, 75, 1, 'OutExpo') -- at beat 4, move mycoolroom's x position to 75% with a duration of 1 beat and OutExpo ease
Moves the room to y
% on the y axis at beat beat
with a duration duration
and ease ease
.
Example:
mycoolroom:movey(6, 30, 0, 'OutQuad') -- at beat 6, move mycoolroom's y position to 30% with a duration of 0 beats and OutQuad ease
Scales the room on the x axis to x
% with a duration duration
and ease ease
.
Example:
mycoolroom:movesx(8, 200, 1, 'InQuint') -- at beat 8, set mycoolroom's horizontal size to 200% with a duration of 1 beat and InQuint ease.
Scales the room on the y axis to y
% with a duration duration
and ease ease
.
Example:
mycoolroom:movesy(6, 150, 1, 'InQuint') -- at beat 6, set mycoolroom's vertical size to 150% with a duration of 1 beat and InQuint ease.
Rotates the room to rot
degrees with a duration duration
and ease ease
.
Example:
mycoolroom:rotate(3, 90, 0.5, 'OutSine') -- at beat 3, rotate mycoolroom to 90 degrees with a duration of 0.5 beats and OutSine ease.
Moves the room's pivot to x
% on the x axis at beat beat
with a duration duration
and ease ease
.
Example:
mycoolroom:movepx(4, 75, 1, 'OutExpo') -- at beat 4, move mycoolroom's x pivot to 75% with a duration of 1 beat and OutExpo ease
Moves the room's pivot to y
% on the y axis at beat beat
with a duration duration
and ease ease
.
Example:
mycoolroom:movepx(4, 75, 1, 'OutExpo') -- at beat 4, move mycoolroom's y pivot to 75% with a duration of 1 beat and OutExpo ease
A helper function to make creating multiple movements at once easier. p
is a key-value table where the key is what function to call and the value is the parameter.
Example:
mycoolroom:move(2, { -- at beat 2,
x = 40, -- move the room to 40% on the x axis,
sy = 0.5, -- scale the room to half its size on the y axis,
rotate = 90, -- rotate the room by 90 degrees, (you can also use rot!)
}, 1, 'Linear') -- with a duration of 1 beat and Linear ease.
Moves the room's camera to x
% on the x axis at beat beat
with a duration duration
and ease ease
.
Example:
mycoolroom:camx(4, 75, 1, 'OutExpo') -- at beat 4, move mycoolroom's camera's x position to 75% with a duration of 1 beat and OutExpo ease
Moves the room's camera to y
% on the y axis at beat beat
with a duration duration
and ease ease
.
Example:
mycoolroom:camy(6, 30, 0, 'OutQuad') -- at beat 6, move mycoolroom's camera's y position to 30% with a duration of 0 beats and OutQuad ease
Zooms in the room's camera to zoom
%.
Example:
mycoolroom:camzoom(8, 200, 1, 'InQuint') -- at beat 8, zoom in mycoolroom's camera to 200%.
Rotates the room's camera to rot
degrees with a duration duration
and ease ease
.
Example:
mycoolroom:camrot(3, 90, 0.5, 'OutSine') -- at beat 3, rotate mycoolroom's camera to 90 degrees with a duration of 0.5 beats and OutSine ease.
A helper function to make creating multiple movements at once easier. p
is a key-value table where the key is what function to call and the value is the parameter.
Example:
mycoolroom:cam(2, { -- at beat 2,
x = 40, -- move the room's camera to 40% on the x axis,
zoom = 200, -- zoom in the room's camera to 200%, (you can also use z!)
rot = 90, -- rotate the room's camera by 90 degrees, (you can also use r!)
}, 1, 'Linear') -- with a duration of 1 beat and Linear ease.
Flips or unflips the room horizontally based on the state
at beat beat
.
Omit state
in order to toggle it instead!
Example:
mycoolroom:xflip(2, true) -- flips horizontally at beat 2
mycoolroom:xflip(5, false) -- unflips horizontally at beat 5
mycoolroom:xflip(6) -- flips horizontally at beat 6
Flips or unflips the room vertically based on the state
at beat beat
.
Omit state
in order to toggle it instead!
Example:
mycoolroom:yflip(2, true) -- flips vertically at beat 2
mycoolroom:yflip(5, false) -- unflips vertically at beat 5
mycoolroom:yflip(6) -- flips vertically at beat 6
Sets the room's stretch mode based on the state
at beat beat
.
Omit state
in order to toggle it instead!
Example:
mycoolroom:stretchmode(2, true) -- room stretches from beat 2
mycoolroom:stretchmode(5, false) -- room no longer stretch 😔 at beat 5
mycoolroom:stretchmode(6) -- room stretch again at beat 6
Sets the room's mask to the array filenames
, with an fps fps
at beat beat
.
You can omit filenames
if you want to unset the room's mask, or you can set it to a single string if you're just using one image.
Note you still need the file extensions.
Example:
mycoolroom:mask(2, {'bg.png', 'fg.png'}, 30) -- set the room's mask to the two images 'bg.png' and 'fg.png' at beat 2
mycoolroom:mask(5, {'bg.png'}) -- set the room's mask to the single image 'bg.png' at beat 5
mycoolroom:mask(6, '') -- unset the room's mask at beat 6
mycoolroom:mask(7, 'fg.png') -- set the room's mask to the single image 'fg.png' at beat 7
mycoolroom:mask(8) -- unset the room's mask at beat 8
Sets the room's perspective to the array pos
at beat beat
.
pos
is an array of points: {x, y}
, the point's x position and y position respectively.
Points are in this order: bottom-left (default: {0, 0}), bottom-right (default: {100, 0}), top-left (default: {0, 100}), top-right (default: {100, 100}).
You can omit one coordinate from the points or an entire point.
Example:
mycoolroom:setperspective(2, { -- at beat 2,
{20, 0}, -- move the bottom-left point to 20 on the x and 0 on the y,
{}, -- don't move the bottom-right point at all,
nil, -- don't move the top-left point at all,
{80, nil} -- move the top-right point to 80 on the x and don't move it on the y,
}, 1, 'OutExpo') -- with a duration of 1 beat and OutExpo easing.
room:floatingtext(beat, text, times, x, y, size, angle, mode, showChildren, color, outlineColor, anchor, fadeOutRate)
Creates a floating text at beat beat
with the text text
at x
and y
. Its size is size
(pixels? no idea), rotated at angle
degrees, its text color is color
and outline color is outlineColor
.
anchor
dictates how it should be anchored should either be 'MiddleLeft'
, 'MiddleCenter'
, 'MiddleRight'
, 'UpperLeft'
, 'UpperCenter'
, 'UpperRight'
, 'LowerLeft'
, 'LowerCenter'
or 'LowerRight'
.
times
is an array of numbers of when the text should advance, relative to the initial floating text event.
mode
is how it should fade out: 'FadeOut'
makes it slowly fade out for fadeOutRate
beats, while 'HideAbruptly'
makes it disappear instantly after fadeOutRate
beats.
color
and outlineColor
are strings in hexadecimal format, like ff0000
.
Example:
mycoolroom:floatingtext(3.5, 'Yo!\nYo, again!\nwoo', {1, 3}, 50, 50, 16, 0, 'FadeOut', true, 'ff0000', '0000ff', 'MiddleCenter', 2)
-- at beat 3.5, make a floating text at 50x 50y, with a size of 16 and 0 rotation, and have it advance after 1 beat to 'Yo, again!' and then, 2 beats later (3 beats after the initial event, 2 beats after the previous advance) advance to 'woo'
-- additionally, text color is red ('ff0000') and outline color is blue ('0000ff')
Set the room's theme to theme
at beat beat
.
Example:
mycoolroom:settheme(2, "OrientalTechno") -- set the theme to Samurai Techno at beat 2
Enable or disable the preset preset
according to state
.
Omit state
in order to toggle it instead!
More preset options later.
Example:
mycoolroom:setpreset(2, 'rain', true) -- enable rain at beat 2
mycoolroom:setpreset(4, 'rain', false) -- disable rain at beat 4
mycoolroom:setpreset(5, 'sepia') -- enable sepia at beat 5
If property
is omitted, returns whether the preset's enabled. Otherwise, returns the value of the property.
Example:
print(mycoolroom:getpreset(2.5, 'rain')) -- print whether or not the rain preset active at beat 2.5
print(mycoolroom:getpreset(3, 'rain', 'intensity')) -- print the rain preset's intensity at beat 3
Flashes the room at beat beat
, starting at the color startcolor
with an opacity of startopacity
, transitioning to a color of endcolor
with an opacity of endopacity
for duration
beats, with ease
easing.
If bg
is true, it will flash in the background layer.
startcolor
and endcolor
are strings in hexadecimal format, like "ffffff"
, where the first two characters represent the red color, the next two represent green and the last two represent blue.
Omitting endcolor
and endopacity
will set them to startcolor
and startopacity
respectively.
Example:
mycoolroom:flash(2, 'ffffff', 100, nil, 0, 2, "InQuint", false) -- flash the room in the foreground at beat 2, starting at white with an opacity of 100 and ending at white with an opacity of 0, over 2 beats and with InQuint easing.
## room:pulsecamera(beat, count, frequency, strength)
Pulse the room's camera at beat `beat` for `count` times (must be at least 1), with `frequency` beats between each pulse and `strength` strength.
`strength` must be 0, 1 or 2.
Example:
```lua
mycoolroom:pulsecamera(2, 3, 0.5, 1) -- at beat 2, pulse the camera 3 times every 0.5 beats at a strength of 1
Shows either the left, right or both hands at beat beat
. instant
dictates whether the hand(s) show up instantly or they smoothly move into view. If align
is true, the hands will align with the room's visible area.
hand
is a string and should either be "Left"
, "Right"
or "Both"
, changing which hand is shown (or both, in the case of Both
).
Example:
mycoolroom:showhand(1, 'Left', false, true) -- at beat 1, show the left hand smoothly and align it to the room's visible area
Hides either the left, right or both hands at beat beat
. instant
dictates whether the hand(s) hide instantly or they smoothly move out of view. If align
is true, the hands will align with the room's visible area.
hand
is a string and should either be "Left"
, "Right"
or "Both"
, changing which hand is hidden (or both, in the case of Both
).
Example:
mycoolroom:hidehand(1, 'Left', false, true) -- at beat 1, hide the left hand smoothly and align it to the room's visible area
Shows/hides either the left, right or both hands if they're already hidden/shown, respectively, at beat beat
. instant
dictates whether the hand(s) show/hide instantly or they smoothly move into/out of view. If align
is true, the hands will align with the room's visible area.
hand
is a string and should either be "Left"
, "Right"
or "Both"
, changing which hand is shown/hidden (or both, in the case of Both
).
Example:
mycoolroom:togglehand(1, 'Left', false, true) -- at beat 1, show the left hand smoothly and align it to the room's visible area
mycoolroom:togglehand(2, 'Left', true, true) -- at beat 2, hide the left hand instantly and align it to the room's visible area
If bgtype
is "Image"
, sets the background image to filenames
with fps
fps, mode
content mode, filter
filter and colored color
. Additionally, if mode
is set to "Tiled"
, the background will scroll by sx
and sy
pixels per second.
If bgtype
is "Color"
, sets the background to a solid color, color
.
Valid content modes are "ScaleToFill"
, "AspectFit"
, "AspectFill"
, "Center"
and "Tiled"
.
color
is a string in hexadecimal format, like ffffffff
, where the first two characters represent red, next two represent green, next two represent blue and the last two represent the opacity.
filenames
can either be an array of strings or one string.
filter
can either be "NearestNeighbor"
or "Bilinear"
.
Example:
mycoolroom:setbg(1, {'bg.png', 'fg.png'}, 'Image', 30, 'ScaleToFill', nil, nil, 'ff0000ff') -- at beat 1, set the room's background to 'bg.png' and 'fg.png' with a fps of 30, with 'ScaleToFill' content mode and colored 'ff0000ff', or red
Sets the foreground image to filenames
with fps
fps, mode
content mode, filter
filter and colored color
. Additionally, if mode
is set to "Tiled"
, the foreground will scroll by sx
and sy
pixels per second.
Valid content modes are "ScaleToFill"
, "AspectFit"
, "AspectFill"
, "Center"
and "Tiled"
.
color
is a string in hexadecimal format, like ffffffff
, where the first two characters represent red, next two represent green, next two represent blue and last two represent the opacity.
filenames
can either be an array of strings or one string.
filter
can either be "NearestNeighbor"
or "Bilinear"
.
Example:
mycoolroom:setfg(1, {'bg.png', 'fg.png'}, 30, 'ScaleToFill', nil, nil, 'ff0000ff') -- at beat 1, set the room's foreground to 'bg.png' and 'fg.png' with a fps of 30, with 'ScaleToFill' content mode and colored 'ff0000ff', or red
At beat beat
, fade the room to opacity
opacity for duration
beats with ease
easing.
Example:
mycoolroom:fade(2, 50, 1, "OutQuint") -- at beat 2, fade the room to 50% opacity for 1 beat with OutQuint easing
At beat beat
, play a bassdrop effect with strength
strength.
strength
should be a string, either Low
, Medium
or High
, dictating the strength of the effect.
Example:
mycoolroom:bassdrop(1, 'Medium') -- at beat 1, play a medium bass drop effect
At beat beat
, play a shake effect with shakelevel
strength.
shakelevel
should be a string, either Low
, Medium
or High
, dictating the strength of the effect.
Example:
mycoolroom:shake(1, 'Medium') -- at beat 1, play a medium shake effect
Sets whether or not the room's colors are inverted at beat beat
.
Omit state
in order to toggle it instead!
Example:
mycoolroom:invertcolors(1, true) -- invert the colors at beat 1
mycoolroom:invertcolors(2, false) -- revert the colors at beat 2
mycoolroom:invertcolors(3) -- invert the colors again at beat 3
mycoolroom:invertcolors(4) -- revert the colors again at beat 4
Creates a text explosion effect at beat beat
, with the text text
, color mode mode
, direction direction
and color color
.
color
is a string in hexadecimal format, like '000000', where the first two characters represent red, next two represent green and the last two represent blue.
mode
is a string and should be either 'OneColor'
or 'Random'
.
direction
is a string and should be either 'Left'
or 'Right'
.
Example:
mycoolroom:textexplosion(1, 'Text', 'ff0000', 'OneColor', 'Right') -- create a text explosion at beat 1, each with the text `Text` and colored `ff0000`, or red, moving from the left to the right
Creates or removes a stutter effect at beat beat
, depending on action
.
action
should be either Add
or Cancel
, with Add
creating a stutter effect and Cancel
cancelling it.
sourcebeat
is the beat to stutter from.
length
is how long each loop is, in beats.
loops
is how many loops we do.
Example:
mycoolroom:stutter(2, 'Add', 1, 0.5, 4) -- create a new stutter at beat 2, with the source beat 1, length 0.5 and 4 loops
mycoolroom:stutter(3, 'Cancel', 1, 0.5, 4) -- cancel the previous stutter. note that the parameters after Cancel do not affect this in any way
Additionally, each room-specific function can be called in the form: level:function(beat, room, ...)
, where room
is the room's index and ...
are the function parameters.
For functions that can be applied on-top, they can also be called level:ontopfunction(beat, ...)
.
On-top functions: setbg
, setfg
, flash
, bassdrop
, shake
, xflip
, yflip
, floatingtext
, camx
, camy
, camzoom
, camrot
, sepia
, tile2
, tile3
, tile4
, noise
, glitchobstruction
, hallofmirrors
, hom
, blackandwhite
, grayscale
, tilen
, screentile
, customscreenscroll
, screenscroll
.
Example:
level:sepia(1, 1, true) -- enable sepia on room 2 at beat 1
level:ontopsepia(2, true) -- enable sepia on-top at beat 2
level:sepia(3, 4) -- toggle (thus, disable) sepia on-top at beat 3