In EX-XDRiVER, the importance of background events are often overlooked, as the camera and track motions that compose mods typically steal the spotlight. Despite this, background events are very important. A chart with mods but no background events may still feel as if it is missing something.
In XDRV, background events take a variety of forms. One common type of background event is the manipulation of alpha values (opacities) of visual elements in the background. Similarly, background events can be used to change the alpha values of UI components and the intensity and diffusion of bloom. Many backgrounds have additional, more specialized events. Whether it be visual overlays or moving components, the background you pick for your chart determines what background events you’ll have access to.
Which background you use is not the only decision behind background events, however. Before you write any background events, you can decide whether to write your events directly into the .xdrv file or into the .lua file with function calls. Both approaches have pros and cons.
To write background events directly into a .xdrv file, you must open the file and navigates to the beat (the line of notes at that beat) that you want the event to occur at. You must then create a #EVENT line above the beat, populating it with the necessary information for the mod to work.
#EVENT
#EVENT=EventName,AdditionalParameters...
Performs a background event at the next beat subdivision in the .xdrv file.
Parameters:
EventName: The name of the event to call.
AdditionalParameters: A sequence of additional parameters. The type and quantity of these parameters depends on which event (and therefore, which event name) is being called.
All together, an event timing segment within a chart looks like this:
--
// B100
010-010|00|0
#EVENT=EasePathAlpha,0.5,1,false,InOutQuad
010-010|00|0 // background event starts here
--
This event eases the background’s path alpha to 0.5 using an InOutQuad ease function. The event starts at beat 100.5 and lasts 1 beat, ending at beat 101.5.
If you would rather add their events to your modfile as opposed to your .xdrv file, you can do so using function calls. In specific, the xdrv.RunEvent function allows you to execute any supported background event from within your .lua modfile.
Performs a background event at a particular beat or time.
Parameters:
eventName: string
The name of the event to call.
beatOrTime: string
Whether to measure timeValue as "beat"s or "time" in seconds.
timeValue: number
The beat or time in seconds to start the background event at, depending on what beatOrTime is.
additionalParameters…
A sequence of additional parameters. The type and quantity of these parameters depends on which event (and therefore, which event name) is being called.
-- Starts at beat 100.5 and lasts 1 beat (ends at beat 101.5)
-- Follows the InOutQuad easing function.
When used in tandem with Lua functionality such as loops, helper functions, and reading note data, background events can be automated to initiate several events with only a few lines. (If you’re not sure what that functionality looks like, you should check the Lua guide in this charting guide).
Depending on your skill level and the software you use to create charts, you may find one method of creating background events more appealing than the other. Generally, if you are decently familiar with the Lua language and can write a few lines, doing background events in the .lua file is more efficient. If coding isn’t your forte, however, you may find writing background events in the .xdrv file to be more ideal. With that said, pros and cons for each method do exist:
Knowing how to create background events is a great place to start. Creating interesting background events for a chart can make the chart feel more full and impactful. With that in mind, knowing the most optimal way to use different types of background events is a challenge in of itself; this challenge will discussed in the next section.