Module:Ships data/doc

From Corsair Cove Official Wiki
Revision as of 19:36, 7 August 2026 by Aeredor (talk | contribs) (updated doc with enriched fields. added section on exported types.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is the documentation page for Module:Ships data

Ship data for Corsair Cove: 29 ships, schema validated at load time.

Use from other modules and templates via #invoke or require:

local ships_data = require("Module:Ships_data")

Functions

Important: Do not mutate returned tables. To save performance, the tables are not copied first. Modifications to the returned values will contaminate other uses of those tables.

get_ship_by_name

Returns one ship record, or nil if the name isn't found.

local ship = ships_data.get_ship_by_name("Landlubber")

Name must match exactly, including spaces, for example "Iron Fist".

get_ship_by_index

Returns the ship record at that position in canonical order, or nil if out of range. Canonical order is from Tier 1 to 6, clockwise starting from the top around the Compass.

local ship = ships_data.get_ship_by_index(1)

get_all_ships

Returns the full array of ship records, in canonical order. Canonical order is from Tier 1 to 6, clockwise starting from the top around the Compass.

for i, ship in ipairs(ships_data.get_all_ships()) do
  ...
end

get_count_of_ships

Returns the number of ships.

for i = 1, ships_data.get_count_of_ships() do
  local ship = ships_data.get_ship_by_index(i)
end

get_ship_class_description

Flavour text for the class of ship, aligned with the Principle Paths. Pass in the class or hybrid_class field from a ship record to get its description. (The method ignores any trailing plus signs for the hybrid ships. Returns nil for unknown classes.

local flavour_text = ships_data.get_ship_class_description("Destroyer+")

Types

The module's exported functions and returned records are typed using LuaCATS-style annotations in the module's source. These aren't enforced at runtime, but document the exact shape of every value the module returns.

ShipRecord

A single ship's full data. See Ship record shape below for field-by-field details.

ShipResourceAmount

A { resource, qty } pair used in construction_costs.

ShipCrewAmount

A { type, qty } pair used in crew_types.

ShipStatAmount

A { stat, qty } pair used in stats_base and stats_crew_bonuses.

ShipUnlockAmount

A { path, qty } pair used in unlock_points.

ShipsDataModule

The shape of the table returned by require("Module:Ships_data") — i.e. the functions documented above.

Ship record shape

Each record in ships_data is a table with the following fields:

Field Type Note
name string Display name
tier number 1..6, inclusive
principle_path string Primary Principle Path alignment of the class of ship
class string Primary class of the ship, with an trailing plus sign for hybrids, similar to their in-game display, for example "Notoriety"
hybrid_path string Secondary Principle Path alignment of the class of ship, according to the unlock requirement on the Compass (never has a trailing plus sign)
icon_filename string The filename, including the extension, of the image of the ship, for example, "T_Ship_Starter.png"
pier string The pier required to build the ship, for example, "Shallow Pier"
description string The English-language flavour text of the ship
construction_costs array of ShipResourceAmount pairs of { resource, qty } mini-tables, where the resource is the name of the construction material, for example, "Naval Gun"
crew_types array of ShipCrewAmount pairs of { type, qty } mini-tables, where the type is the name of the crew as spelled in-game, for example, "Crow's Eyes"
stats_base array of ShipStatAmount pairs of { stat, qty } mini-tables, where stat is the name of the stat as spelled in-game, for example, "Gun Damage" or "Manoeuvrability"
stats_crew_bonuses map of arrays of ShipStatAmount by crew_type's type, each returns an array of { stat, qty } like stats_base but showing the marginal bonus per additional individual crew member of that type
stats_max array of ShipStatAmount calculated table of the maximum stats with the most number of advanced crew, similar structure to stats_base
unlock_points array of ShipUnlockAmount calculated pairs of { path, qty } mini-tables based on the ship's principle_path and hybrid_path

Nested pairs

Construction, crew, and stats use ordered arrays of pairs of data: The first field is a resource's, crew type's , or stat's name, as spelled in-game, and the second field is the quantity.

  • ship.construction_costs is an array of ShipResourceAmount, resource–qty pairs.
  • ship.crew_types is an array of ShipCrewAmount, type–qty pairs.
  • ship.stats_base is an array of ShipStatAmount, stat–qty pairs.
  • ship.stats_crew_bonuses is several arrays of ShipStatAmount, stat–qty pairs.
  • ship.stats_max is an array of ShipStatAmount, stat-qty pairs.
  • ship.unlock_points is an array of ShipUnlockAmount, path-qty pairs.

Crew bonuses

The bonuses are first keyed by the crew type's name. Keys match that ship's crew_types types. Typed in the table are fractional values of what is shown in-game divided by the number of crew. This means when working with this data, each individual value in the stat–qty pair is the marginal additional stat that one crew member contributes to the ship.

local bonuses = ship.stats_crew_bonuses["Scallywags"]

To get the highest possible maximum stats, use ship.stats_max instead, which is pre-calculated.