From Dark and Darker Wiki
(init) |
m (create_achievements_table_body init) |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local achievements = mw.loadJsonData("Data:Achievements.json") | local achievements = mw.loadJsonData("Data:Achievements.json") | ||
function p.create_achievements_table_body(achievements, debug_mode) | |||
local html = "" | |||
local record | |||
for index, achievement in ipairs(achievements) do | |||
record = "<tr>\n" | |||
record = record .. "<td>" .. (achievement.localized_name) .. "</td>\n" | |||
record = record .. "<td>" .. (achievement.main_category) .. "</td>\n" | |||
record = record .. "<td>" .. (achievement.sub_category) .. "</td>\n" | |||
record = record .. "<td>" .. (achievement.prerequisite) .. "</td>\n" | |||
record = record .. "<td>" .. (achievement.description) .. "</td>\n" | |||
record = record .. "</tr>\n" | |||
html = html .. record .. "\n" | |||
end | |||
if debug_mode == nil or debug_mode ~= 'false' then | |||
return html | |||
else | |||
return mw.getCurrentFrame():preprocess(html) | |||
end | |||
end | |||
return p | return p |
Revision as of 03:41, 22 December 2024
Overview
Functions for Data:Achievements.json
Functions
create_achievements_table_body
Creates the body of a html function with 6 pre-set columns
Parameters
- hidden_or_nonhidden - defaults to nonhidden - must be hidden or nonhidden - Displays only hidden or nonhidden achievements
Examples
Ensure to surround it by html table and its headers:
<table class="wikitable sortable"> <tr> <th>Name</th> <th>Icon</th> <th>Category</th> <th>Sub-Category</th> <th>Pre-requisite</th> <th>Description</th> </tr> {{#invoke:Achievements|create_achievements_table_body}} </table>
Name | Icon | Category | Sub-Category | Pre-requisite | Description |
---|
Example of hidden achievements only
<table class="wikitable mw-collapsible mw-collapsed"> <tr> <th>Name</th> <th>Icon</th> <th>Category</th> <th>Sub-Category</th> <th>Pre-requisite</th> <th>Description</th> </tr> {{#invoke:Achievements|create_achievements_table_body|hidden}} </table>
Name | Icon | Category | Sub-Category | Pre-requisite | Description |
---|
local p = {}
local achievements = mw.loadJsonData("Data:Achievements.json")
function p.create_achievements_table_body(achievements, debug_mode)
local html = ""
local record
for index, achievement in ipairs(achievements) do
record = "<tr>\n"
record = record .. "<td>" .. (achievement.localized_name) .. "</td>\n"
record = record .. "<td>" .. (achievement.main_category) .. "</td>\n"
record = record .. "<td>" .. (achievement.sub_category) .. "</td>\n"
record = record .. "<td>" .. (achievement.prerequisite) .. "</td>\n"
record = record .. "<td>" .. (achievement.description) .. "</td>\n"
record = record .. "</tr>\n"
html = html .. record .. "\n"
end
if debug_mode == nil or debug_mode ~= 'false' then
return html
else
return mw.getCurrentFrame():preprocess(html)
end
end
return p