WePlay: Flight Library


Shared flight code for WePlay airplane mods: runway takeoffs and landings, turn-radius paths, circling, formation flying, altitude, shadows and banking. Does nothing on its own.

Internal
a day ago
2.1
28
Owner:
afewvowels
Source:
https://github.com/afewvowels/WePlayFlightLib
Homepage:
N/A
License:
The Unlicense (Public Domain)
Created:
a day ago
Latest Version:
0.1.5 (a day ago)
Factorio version:
2.1
Downloaded by:
28 users

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:

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.