Module:Feature page
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Feature page/doc
local p = {}
local yesno = require('Module:Yesno')
function p.scribing(frame)
local frame_args = frame:getParent().args
local name = frame_args.name or ""
name = mw.text.trim(name)
name = name ~= "" and name or mw.title.getCurrentTitle().text
local level_int = tonumber(frame_args.level) or 0
local raw_scribing_input = frame_args.scribing or ""
local split_scribing_input = mw.text.split(raw_scribing_input, ":", true)
local override_name = #split_scribing_input > 1 and mw.text.trim(split_scribing_input[2]) or ""
local scroll_name = override_name ~= "" and override_name or "Scroll of " .. name
scroll_name = scroll_name:gsub("'", "''")
scroll_name = scroll_name:gsub("\\", "")
local raw_can_scribe = mw.text.trim(split_scribing_input[1])
local can_scribe_manual = raw_can_scribe ~= ""
local can_scribe = yesno(raw_can_scribe, true)
local out = ""
local level = level_int > 1 and " with a" .. frame:expandTemplate{
title = 'r',
args = { "spell" .. level_int } } or ""
local params = {
where = "type = 'Scrolls' AND name = '" .. scroll_name .. "'",
limit = 2
}
local data = mw.ext.cargo.query("misc_items", "name, legacy", params)
local scroll_exists = #data > 0
if #data > 1 then out = out .. "[[Category:Overlength cargo return]]" end
local null_out = "no◆" .. "* " .. out .. "There are no scrolls available for [[wizard]]s to [[Transcribing scrolls|transcribe]] to their spellbooks."
if not scroll_exists then return null_out end
local scroll_link = frame:expandTemplate{
title = 'RarityItem',
args = { data[1].name } }
local scroll_legacy = data[1].legacy
if scroll_legacy and scroll_legacy ~= "" then
--Keep these in line with Template:Legacy/Table
if scroll_legacy == "legacy" then return null_out .. " " .. scroll_link .. " has been entirely removed from the game." end
if scroll_legacy == "unobtainable" then return null_out .. " " .. scroll_link .. " is unobtainable without third party tools." end
if scroll_legacy == "unusable" then return null_out .. " " .. scroll_link .. " is unusable without exploits or third party tools." end
if scroll_legacy == "inacessible" then return null_out .. " " .. scroll_link .. " is inacessible without exploits or third party tools." end
--scroll_link = scroll_link .. " (" .. scroll_legacy .. ") "
--can_scribe = can_scribe and can_scribe_manual
--lefover code for leaving the link inline with a note
end
out = "* " .. out .. "[[Wizard]]s "
out = can_scribe and "yes◆" .. out .. level .. " can" or "no◆" .. out .. "''cannot''"
return out .. " [[Transcribing scrolls|transcribe]] a ".. scroll_link .. " to their spellbooks."
end
return p