Lua scripting

Screen effects

Blood at the edges, a shaking camera, a drunk sway, slow motion: effects a scene plays over the picture, defined as mod data and stacked freely.

A screen effect is something that happens to the player's view for a few seconds: the screen shakes when they are hit, the edges go red while they bleed, the room sways after the fifth drink. A scene plays one with a single call, and several can run at once. What each effect looks like is a small file in a mod, so you can use the twenty-four that ship with the game or write your own.

luaGame:Effect("bloody")                              -- Effects/bloody.uleffect, as written
Game:Effect("drunk", { seconds = 20, strength = 0.6 })
Game:Effect("shake")
Game:StopEffect("drunk", 2)                        -- fade one out over 2 seconds
Game:StopEffect()                                  -- fade every effect out
for _, name in ipairs(Game:EffectNames()) do Game:Log(name) end
Call Does
Game:Effect(name [, options]) Plays Effects/<name>.uleffect from any enabled mod. options: seconds (0 runs until stopped), strength (multiplies the effect, 1 as written, up to 3), fadeIn, fadeOut. Playing an effect that is already running restarts it. Returns false, with a line in the log, when no mod defines it.
Game:StopEffect([name] [, seconds]) Fades that effect out (all of them without a name) over seconds, or over its own fadeOut.
Game:EffectNames() Every effect the enabled mods define, sorted.

Effects run in real time and outlive the scene that started them: a scene can end on Game:Effect("blurry", { seconds = 6 }) and the player walks out of it still dizzy. They sit under every piece of interface, so a line of dialogue or a button is never hidden by blood on the lens.

The effects that ship

ul_Base/Effects/ holds these. Use them as they are, or copy one into your mod under a new name and change it.

Name What it is
shake A hard jolt: a blow, a fall, a door kicked in.
tremor Hands that won't keep still: fear, cold, withdrawal.
pain A hit that hurts: a red flash, the edges going dark and red.
bloody Hurt and bleeding: red at the edges, closing in with the heartbeat.
blood_splatter Blood on the lens, running down.
blurry Everything out of focus: tired, drugged, just woken.
drunk The room won't hold still and the lights smear.
drugged Colours too bright, edges splitting, the floor breathing.
heartbeat A heart pounding in the ears; the world narrowing on each beat.
tunnel Tunnel vision: panic, rage, a narrowing world.
faint Going under: the room tilting, black from the edges.
concussion A blow to the head: white, ringing, everything doubled.
adrenaline Sharp, fast, every detail; time stretching a little.
slowmo Slow motion: the moment stretched out.
dream Soft, warm, glowing at the edges.
flashback A memory: washed-out sepia, grain, a white flash in.
cold Freezing: blue, frost creeping in, shivering.
heat Heat: glare, a shimmer, the air too thick.
tears Crying: the picture swimming behind wet eyes.
crack Something hits the glass, or the face: a starburst of cracks.
static Interference: a bad signal, something wrong with reality.
psychic A power used: violet at the edges, a pressure behind the eyes.
nausea Sick: the room rolling, green at the edges.
blackout Out cold: the picture goes black.

Writing an effect: .uleffect

An effect is a Lua table in Effects/<name>.uleffect; the file name is the effect's name, and a later mod's file of the same name replaces it. Every key is optional: write only the pieces the effect needs.

lua-- Effects/ynl_poisoned.uleffect
return {
	seconds = 8, fadeIn = 1, fadeOut = 2,
	pulse = { hz = 0.5, depth = 0.4 },
	sway = { roll = 2, yaw = 1.5, hz = 0.15 },
	grade = { saturation = 0.5, tint = { 0.85, 1.05, 0.75 }, blur = 0.3 },
	overlay = { image = "Effects/sick_edges.png", opacity = 0.8 },
	cue = "Effect.Heartbeat",
}
Key Means
seconds How long it plays, in real seconds (3). 0 runs until Game:StopEffect.
fadeIn, fadeOut Seconds to come in and to go (0.2, 0.8).
grade What the picture leans towards, with the keys of a grade: tint { r, g, b }, saturation, contrast, gamma, vignette, grain, bloom, chroma, blur (0..1), exposure (stops), temperature (Kelvin). The effect blends towards these values by its current strength, on top of whatever the venue and a scene's Game:Grade already do.
shake Camera shake: a number 0..1 (a blow is about 0.6), or { amount, hz } for its speed (12).
sway { roll, yaw, hz }: the view rocking, in degrees, at that speed (0.25).
zoom Degrees added to the field of view; negative closes in.
pulse { hz, depth, shape }: the effect's strength beats at hz, dropping to 1 - depth between beats. shape is "sine" (default), "heartbeat" (a double beat, then rest) or "flicker" (random).
overlay, overlays One image, or a list, stretched over the screen. An image is Images/<path> in any mod: { image = "Effects/blood_edges.png", opacity = 1, color = { r, g, b, a }, pulse = true, jitter = 0, grow = 0 }. pulse = false keeps it steady while the rest beats; jitter (fraction of the screen) shakes it every frame, like TV static; grow makes it bigger between beats so the edges close in on each one.
flash { color = { r, g, b }, seconds = 0.3 } at the start, as Game:Flash.
cue An audio cue played once at the start (Sound). ul_Base has Effect.Heartbeat, Effect.Tinnitus, Effect.Thud, Effect.Static and Effect.Whoosh.
timeScale The world's speed while it runs (0.25 is slow motion), easing in and out with the effect.

The images ul_Base ships under Images/Effects/: blood_edges, blood_splatter, dark_edges, frost, droplets, static, cracks, glow, psychic, sick_edges, and black (a plain black, for going dark: an overlay of it at an opacity is the reliable way to darken the screen). Overlays are PNGs with transparency, any size (they are stretched to the screen; 1280×720 is plenty).

warning

exposure changes nothing in the rooms: their camera keeps a fixed exposure (no eye adaptation), so the bias has nothing to act on. To darken the picture, use the black overlay at an opacity, as faint and blackout do.

tip

Effects stack. A punch can be Game:Effect("shake") and Game:Effect("pain") at once, and a long Game:Effect("drunk", { seconds = 0 }) can run under everything until your mod stops it the next morning.

modder

ul_Powers defines three effects of its own (ul_pw_unseen, ul_pw_stillness, ul_pw_xray) in its Effects/ folder: a mod's look for its own moments, beside the shared ones.