Module:Ships data/doc

From Corsair Cove Official Wiki
Revision as of 18:14, 7 August 2026 by Aeredor (talk | contribs) (76561197969631737 moved page Module:Ship data.lua/doc to Module:Ships data/doc without leaving a redirect: Misspelled title: Pluralized to match intent. Removed filename extension from Module name)

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+")

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 pairs of { resource, qty } mini-tables, where the resource is the name of the construction material, for example, "Naval Gun"
crew_types array 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 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 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

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 resource–qty pairs.
  • ship.crew_types is an array of type–qty pairs.
  • ship.stats_base is an array of stat–qty pairs.
  • ship.stats_crew_bonuses is several arrays of stat–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"]