12,787
edits
(Refactor _getAreaRequirements & drop dependency on Shop, Items modules) |
(_getAreaRequirements: Resolve cases where requirement text returned could contain empty lines) |
||
(One intermediate revision by one other user not shown) | |||
Line 72: | Line 72: | ||
local resultArray = {} | local resultArray = {} | ||
if area.entryRequirements ~= nil then | if area.entryRequirements ~= nil then | ||
local reqText = Common.getRequirementString(area.entryRequirements) | |||
if reqText ~= nil then | |||
table.insert(resultArray, reqText) | |||
end | |||
end | end | ||
Line 78: | Line 81: | ||
-- Avoid repeating the same requirements twice, can happen for some dungeons e.g. Impending Darkness | -- Avoid repeating the same requirements twice, can happen for some dungeons e.g. Impending Darkness | ||
if area.entryRequirements == nil or mw.dumpObject(area.unlockRequirement) ~= mw.dumpObject(area.entryRequirements) then | if area.entryRequirements == nil or mw.dumpObject(area.unlockRequirement) ~= mw.dumpObject(area.entryRequirements) then | ||
local reqText = Common.getRequirementString(area.unlockRequirement) | |||
if reqText ~= nil then | |||
table.insert(resultArray, reqText) | |||
end | |||
end | end | ||
end | end | ||
return table.concat(resultArray, '<br/>') | return table.concat(resultArray, '<br/>') | ||
end | |||
function p.getAreaRequirementsForBox(frame) | |||
--Returns infobox formatting for requirements, or returns nothing if there are none. | |||
local areaName = frame.args ~= nil and frame.args[1] or frame | |||
local area = p.getArea(areaName) | |||
if area == nil then | |||
return Shared.printError('No area named "' .. areaName .. '" exists in the data module') | |||
end | |||
local reqs = p._getAreaRequirements(area) | |||
if reqs ~= '' then | |||
reqs = "|-\r\n|'''Requirements:'''\r\n"..reqs | |||
end | |||
return reqs | |||
end | end | ||