WePlay: Flight Library
The shared flight code behind WePlay's airplane mods. It does nothing on its own.
You've probably landed here because WePlay: Laser-Equipped Drone Swarms needs it: swarms of laser airplanes that fly out to the biter nests on a one-way trip.
Its flight code started out in WePlay's other airplane mods, which fly the same way:
- âī¸ WePlay: Long Haul Logistics Drones: cargo airplanes linking your outposts to your main base.
- đ°ī¸ WePlay: Radar Probe Drone Launcher: survey airplanes that land as radar probes out in the fog.
Install it and forget about it. It adds no items, buildings, research or settings.
What it does
The little airplanes in those mods are drawn and flown by script, so they cost very little to run. This library is the flying part, written once and shared:
- đĢ Runway takeoffs and landings: a takeoff roll, a climb-out and a straight final approach, with speed and altitude easing in and out.
- âĒī¸ Real turning circles: airplanes fly smooth arcs to where they're going instead of snapping round.
- đ Circling: fly to the best point on a circle, then orbit it.
- đĻ Formation flying: wingmen hold a spot behind a leader, steer like planes, and ease off instead of looping back when they get ahead.
- đŠī¸ Banking: airplanes roll into their turns, either with real banked sprite frames or by squeezing the sprite along its wings.
- đ Shadows that drift away from the airplane as it climbs, plus optional glow layers and map markers.
- đ Flying sounds for airplanes near players, a few at a time, so a big swarm doesn't get deafening.
For modders
Released under the Unlicense, so you're welcome to use it in your own mods. Add WePlayFlightLib as a dependency, then:
local Flight = require("__WePlayFlightLib__/flight")
The library keeps no saved data and registers no events. Your mod keeps its flights in its own storage and calls Flight.step(f) once per tick for each one. The main calls are Flight.new, Flight.fly_to_pad, Flight.fly_to, Flight.orbit, Flight.follow, Flight.step and Flight.destroy. The README in the source repository documents every option, with an example.
Credits
Built for WePlay's airplane mods. See all WePlay mods on the mod portal.