Talk:Suggestion/@comment-25683568-20150227195108

Ship and Equipment Lua Module Conversion Proposal
Kancolle Wiki relies a lot on data. Ship data, equipment data, and many other types of data.

Due to the way wiki works, this data is often spread out among many pages and duplicated everywhere.

Let's say 15.5cm Triple Gun Mount (Secondary) was renamed in a patch to 15.5cm Triple Secondary Gun Mount (note, it actually was and needs changing. So does 15.5 Triple Gun Mount (Main)). Does anyone know all the places 15.5 Triple Gun Mount (Secondary) is referenced? At least all the Kongou-class pages, the Equipment page, the List of Secondary Guns by stats, the equipment's page itself, the Development page. Redirects will help, but the link text stays the same, and needs to be changed manually.

We can fix this by consolidating data in one place. Change the name of 15.5cm Triple Gun Mount (Secondary) there, and it will change everywhere else. As if it was a template.

Let's look at another problem we have. The EliteXX family of pages. The tables are easy to mess up, and if the values are wrong, it is very easy not to notice because when values are updated, it is easy to forget to check the EliteXX pages as well. Not to mention the tables are difficult to edit because of all the rowspan; the wikitext does not reflect the output well and to a new editor it is very difficult to add a new ship to the table, much less update one value.

What if we could tell a template what ships we want, and at what value for each stat highlights should be applied?

These are things we can achieve with Lua modules. We define all the data of a ship or equipment in a module, draw on it in other modules like Module:EliteShipsKai, and use it on pages through wrapper templates like Template:EliteShipsKai.

I have created a prototype of this system already, and you can see how it works at Sandbox/ShipInfoKai, Sandbox/EliteShipsKai, Sandbox/EquipmentInfoKai. This is by no means the extent of what can be done, it is merely a prototype (but in my opinion, it is ready for production use already as it is much better than the current templates we have). You may notice that a lot of the equipment is renamed; I plan to detail this in a separate suggestion at a later time.

Currently, three templates exist that use this new system:

ShipInfoKai
Template:ShipInfoKai is a new ship infobox template. Changes from the current Template:Shipinfo and Template:Shipinfo2 include:


 * Only the ship name and form need to be specified. All data is retrieved from the ship's data module.
 * Improved rarity background coloring, less harsh on the eyes.
 * There is now a separate background color for each rarity except S Holo and SS Holo.
 * Holo, S Holo and SS Holo are now distinguishable on most modern browsers.
 * S Holo will show sparkle lines.
 * SS Holo will show sparkle lines and a red glow.
 * Improved display of the id for forms that don't have an entry in the zukan.
 * The icons and rarity of stock equipment is now shown.
 * There is always space for two rows of text for each stock equipment's name, reducing the need to abbreviate equipment names.
 * Furigana of a ship's japanese name can be seen by hovering over the japanese name.
 * The rarity of the ship (this can different from the background color of the card, see Module:Souryuu Kai Ni) will be shown if hovering over the rarity background color.
 * The max HP after marriage is viewable by hovering over the HP stat value.
 * The modernization bonus has been added to the infobox.
 * The slot sizes are shown even for ships that have no aircraft capacity.
 * The Build Time header changes to Remodel Level for remodeled forms.
 * The remodel cost is shown next to the remodel level.
 * Normal / LSC is shown depending on buildability.
 * Values default to ?? if not specified, rather than remaining empty.
 * Card image defaults to File:Catbomb.png.
 * The ship name is a link to the ship page.

Examples of this template in use can be seen at Sandbox/ShipInfoKai. A more complete set of infoboxes can be seen at Sandbox/ShipInfoKai/CL and Sandbox/ShipInfoKai/CV (beware, very heavy pages!).

EquipmentInfoKai
Template:EquipmentInfoKai is a new equipment infobox template. Changes from the current Template:Equipmentinfo include:


 * Only the equipment name needs to be specified. All data is retrieved from the equipment's data module.
 * Added rarity background coloring similar to ShipInfoKai.
 * Furigana for the ship's japanese name can be seen by hovering over the japanese name.
 * Rather than showing a gallery, only the equipment card image is shown.
 * Add Equipment/Gallery pages???
 * Compatibility notes are now possible. See Torpedo equipment for an example (only FBB compatible is Bismarck drei).
 * Changed the classes shown in the compatibility section.
 * Show hidden torpedo accuracy when hovering over stat bonuses. This stat appears to be unused but is set on some equipment.
 * Values default to ?? if not specified, rather than remaining empty.
 * Card image defaults to File:Catbomb.png.

A sample of infoboxes can be seen at Sandbox/EquipmentInfoKai.

EliteShipsKai
Template:EliteShipsKai is a new template that implements ship comparison tables. It draws on ship data modules to build the table automatically based on a list of ships you provide it, and optional parameters for highlighting and other settings. See the template documentation for usage. It should be much easier to work with that the current tables.

A sample for EliteCL and EliteCV can be seen at Sandbox/EliteShipsKai.

Other modules (Not meant to be accessed from articles)
The following is an explanation of what some of the new pages in this system are.

ShipData
Module:ShipData defines the interface of a ship's data module. Module:Ship is used to get ShipData objects by the ship name and the model of the ship (e.g. Sendai, Kai Ni), and we can get many different things from that ShipData object, like the name of the ship, the bauxite scrap value, whether a blueprint is needed to remodel, the equipment in the fourth slot.

See Template:ShipDataDocumentation for a detailed explanation of the format of each ship data module.

Currently all CL's, CLT's, CT's, and CV's have a ship data module. Unfortunately, Wikia's implementation of Lua is lacking compared to Wikipedia's implementation, so we can't categorize Modules yet. However it is possible categorize Module talk pages I think, so this may be a solution in the mean-time until Wikia updates the MW version/Scribunto version.

EquipmentData
Module:EquipmentData, like Module:ShipData, defines the interface of an equipment's data module. Module:Equipment, like Module:Ship is used to get EquipmentData objects by the equipment name (e.g. Reppuu), and we can get many different things from that EquipmentData object, like the name of the equipment, the bauxite scrap value, the amount of stars it has, the days it can be upgraded in Akashi's Improvement Arsenal by what ship.

See Template:EquipmentDataDocumentation for a detailed explanation of the format of each equipment data module.

Currently, all the stock equipment of every model of all CL's, CLT's, CT's, and CV's have an equipment data module.

Category:Pages with script errors
Of course, since this system is based on code, if something goes wrong, script error will be shown in bold red text. Any article with a script error will be added to Category:Pages with script errors. Clicking the script error will pop up a traceback which can be used to debug the code and fix the script error.

Conclusion
What is everyone's opinion of this system? I think it is much better than what we have now. There will be worries about whether or not new editors can make edits with this system; the data modules of themselves are quite self-explanatory and I think that changing values will not be difficult at all. For the modules that implement the templates themselves, I tried to keep chunks of wikitext near the top of each module and only use code to retrieve values and put together wikitext chunks. I don't aim to replace normal prose with this system, like the background information of equipment or ships; that belongs solely on the ship's main namespace page, just the data and resources that are used in many places.

I know this is a large departure from the current system and quite a giant overhaul of the entire wiki, but I think this is a step that we should take moving forward. Please feel free to ask questions, I'm quite sure I haven't managed to explain everything that I should be.

tl;dr: A new system where data is stored in one place, and pages can use the same data to show whatever they need to show, so that when data changes, all the pages change automatically! Also, complex stuff like tables with rowspan can be built automatically from data, so no more fiddling with rowspan! Yay!