Ilysa by Example: Light

Just as sequences and ranges let you specify when events should be created, lights let you specify which lighting event types and light IDs to trigger.

package main
import (
    "github.com/shasderias/ilysa"
    "github.com/shasderias/ilysa/beatsaber"
    "github.com/shasderias/ilysa/context"
    "github.com/shasderias/ilysa/evt"
    "github.com/shasderias/ilysa/light"
    "github.com/shasderias/ilysa/lightid"
    "github.com/shasderias/ilysa/timer"
)
func main() {
    m, _ := beatsaber.NewMockMap(beatsaber.EnvironmentOrigins, 120, "[]")
    p := ilysa.New(m)

You can specify lighting event types and light IDs manually like so, but unless you are trying achieve a very specific effect, it’s often easier to work with lights.

    p.Sequence(timer.Beat(0), func(ctx context.Context) {
        ctx.NewRGBLighting(
            evt.WithLight(evt.RightRotatingLasers),
            evt.WithLightValue(evt.LightBlueOn),
            evt.WithLightID(lightid.New(1, 2, 3)),
        )
    })

light.NewBasic() takes two arguments, an Ilysa project and a light event type, and returns a basic light. Basic lights don’t set the lightID field when used and are essentially equal to a base game lighting event.

    leftLasers := light.NewBasic(p, evt.LeftRotatingLasers)
    p.Sequence(timer.Beat(0), func(ctx context.Context) {

Use a light by calling ctx.Light() from within a sequence or a range context.

        ctx.Light(leftLasers, func(ctx context.LightContext) {

All lighting events created using ctx will have their event type appropriately set.

            ctx.NewRGBLighting(
                evt.WithLightValue(evt.LightBlueOn),
            )
        })
    })
    p.Dump()
}
$ go run light.go
[
    {"_customData":{"_lightID":[1,2,3]},"_time":0,"_type":3,"_value":1},
    
    {"_time":0,"_type":2,"_value":1}
]

Next, we will look at how we can transform basic lights to achieve more interesting effects.

Next example: Light - Transform.