|
|
| Line 1: |
Line 1: |
| -- Module:AbilityTables
| |
| -- Renders sortable wikitables of abilities filtered by a named stat. | | -- Renders sortable wikitables of abilities filtered by a named stat. |
| -- Backing module for Template:AbilityTable.
| |
| --
| |
| -- Usage on wiki pages: {{AbilityTable|charges}}
| |
| --
| |
| -- ============================================================
| |
| -- ADDING A NEW STAT
| |
| -- ============================================================
| |
| -- 1. Add an entry to stat_to_props mapping the friendly name
| |
| -- (lowercase) to the internal AbilityData property keys that
| |
| -- determine whether an ability appears in the table.
| |
| --
| |
| -- 2. Add a matching entry to extra_columns:
| |
| -- - headers: ordered list of column header strings.
| |
| -- Include "Notes" if this stat generates notes.
| |
| -- - get_cells: function(ability) -> { ["Column Name"] = value }
| |
| -- The ability is guaranteed to match the stat.
| |
| -- Omit a key or return nil to show "—" in that cell.
| |
| -- If no extra_columns entry is added, only Hero and Ability
| |
| -- columns are shown (plus Notes if human notes exist for the stat).
| |
| --
| |
| -- 3. Optionally add human-authored notes to human_notes:
| |
| -- human_notes["stat"]["Ability Name"] = "Note text."
| |
| -- Notes are appended to any renderer-generated note automatically.
| |
| --
| |
| -- 4. Optionally add entries to column_suffix to append a unit
| |
| -- string (e.g. "s", "%") after cell values in specific columns.
| |
| -- ============================================================
| |
|
| |
|
| local p = {}
| |
| local GameData = require("Module:GameData")
| |
|
| |
| -- ============================================================
| |
| -- stat_to_props
| |
| -- Maps lowercase friendly stat names to internal AbilityData | | -- Maps lowercase friendly stat names to internal AbilityData |
| -- property keys used to filter which abilities appear.
| |
| -- ============================================================
| |
| local stat_to_props = { | | local stat_to_props = { |
| ["charges"] = { "AbilityCharges" }, | | ["charges"] = { "AbilityCharges" }, |
| } | | } |
|
| |
|
| -- ============================================================
| |
| -- human_notes
| |
| -- Editor-authored notes appended to the Notes column. | | -- Editor-authored notes appended to the Notes column. |
| -- Keyed first by stat name, then by ability display Name.
| |
| -- ============================================================
| |
| local human_notes = { | | local human_notes = { |
| ["charges"] = { | | ["charges"] = { |
| Line 51: |
Line 12: |
| }, | | }, |
| } | | } |
| | |
| | -- Unit strings appended to cell values by column name. |
| | local column_suffix = { |
| | ["Time Between Charges"] = "s", |
| | } |
| | |
| | -- Actual code below |
| | |
| | local p = {} |
| | local GameData = require("Module:GameData") |
|
| |
|
| -- ============================================================ | | -- ============================================================ |
| Line 74: |
Line 45: |
| return nil | | return nil |
| end | | end |
| | |
|
| |
|
| -- ============================================================ | | -- ============================================================ |
| Line 133: |
Line 105: |
| end | | end |
|
| |
|
| -- ============================================================
| |
| -- extra_columns
| |
| -- Declares headers and cell renderer for each stat.
| |
| -- ============================================================
| |
| local extra_columns = { | | local extra_columns = { |
| ["charges"] = { | | ["charges"] = { |
| Line 142: |
Line 110: |
| get_cells = charges_cells, | | get_cells = charges_cells, |
| }, | | }, |
| }
| |
|
| |
| -- ============================================================
| |
| -- column_suffix
| |
| -- Unit strings appended to non-nil cell values by column name.
| |
| -- ============================================================
| |
| local column_suffix = {
| |
| ["Time Between Charges"] = "s",
| |
| } | | } |
|
| |
|