Module:ManualDescriptions
Manual Description Module
This module exists to allow bulk edits to item descriptions, without the need to edit each page individually. Editing the line item that corresponds to the item description you want to modify will result in that wiki page being modified.
You will notice the default item description will say No description available for ITEMNAME. Please edit Module:ManualDescriptions to add one.. This text is automatically modified when this Module is modified.
How to edit the Module
You are currently reading the /doc page of this module. It automatically inserts to the top of the module for easy reading. To edit the module, click Edit source and follow the instructions below.
Creating a new description
To create a new item description, create a new line in the module BEFORE the } at the end of the description list. This brace indicates the end of the description section of this module. Anything written outside of the { } will not be read appropriately.
- Each new description entry must start on a new line AND start with the name of the item page, written exactly as the item page on the wiki.
- To add a description for the Pearl harpoon page, you would write
["Pearl harpoon"]- This is case sensitive and MUST be enclosed within quotations and a singular bracket.
- To add a description for the Pearl harpoon page, you would write
- Next, type a
=after the bracketed item name to indicate the start of the description text.- At this point, the line should look like this:
["Pearl harpoon"] =
- At this point, the line should look like this:
- Finally, write out your description, making sure it is wrapped in quotation marks, and add a coma to the end of the line after the quotation marks, indicating the line item is complete.
- The finalized result should look like this:
["Pearl harpoon"] = "The description goes here.",
- The finalized result should look like this:
You can repeat this process for any item descriptions you want to create, even if the item page does not yet exist.
Editing an existing description
- If you are editing an existing description, find the item name located in the singular brackets at the beginning of the line.
- If you wanted to edit the Dragonite ore description, look for the line item
["Dragonite ore"]. - From here, you can change any of the text located between the quotation marks.
["Dragonite ore"] = "Edit any of the text within these quotes",
- Note: You can use any formatting within these quotations. This includes linking to pages utilizing the brackets, adding line breaks using
<br>, or any other formatting you wish.
- If you wanted to edit the Dragonite ore description, look for the line item
-- Module:ManualDescriptions
local p = {}
-- Function to parse CSV content
local function parseCSV(csvText)
local data = {}
local lines = {}
-- Split into lines
for line in csvText:gmatch("[^\r\n]+") do
table.insert(lines, line)
end
if #lines < 2 then
return data -- No data to parse
end
-- Skip header line, parse data lines
for i = 2, #lines do
local line = lines[i]
local fields = {}
-- Simple CSV parsing (handles quoted fields with commas)
local fieldstart = 1
repeat
local nexti = nil
if string.sub(line, fieldstart, fieldstart) == '"' then
-- Quoted field
local a, b = string.find(line, '^"(.-)"', fieldstart)
if a then
table.insert(fields, string.sub(line, a+1, b-1))
nexti = b + 2 -- Skip quote and comma
end
else
-- Unquoted field
local a, b = string.find(line, '^([^,]*)', fieldstart)
if a then
table.insert(fields, string.sub(line, a, b))
nexti = b + 2 -- Skip comma
end
end
fieldstart = nexti
until fieldstart == nil or fieldstart > #line
if #fields >= 2 then
data[fields[1]] = fields[2]
end
end
return data
end
function p.getDescription(frame)
local itemName = frame.args[1] or ""
-- Get the CSV page content
local csvTitle = mw.title.new('Data:ManualDescriptions.csv')
if not csvTitle or not csvTitle.exists then
return string.format("''CSV data page [[Data:ManualDescriptions.csv]] not found. Please create it.''")
end
local csvContent = csvTitle:getContent()
if not csvContent then
return string.format("''Could not read CSV data. Please check [[Data:ManualDescriptions.csv]].''")
end
-- Parse the CSV
local descriptions = parseCSV(csvContent)
local description = descriptions[itemName]
if description then
return description
end
return string.format("''No description available for %s. Please edit [[Data:ManualDescriptions.csv]] to add one.''", itemName)
end
return p