More actions
Content deleted Content added
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
(19 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
text = 'Corporeal', |
text = 'Corporeal', |
||
link = 'Corporeal undead creatures', |
link = 'Corporeal undead creatures', |
||
symbol = ' |
symbol = '🧟♀️', |
||
}, |
}, |
||
skeletal = { |
skeletal = { |
||
text = 'Skeletal', |
text = 'Skeletal', |
||
link = 'Skeletal undead creatures', |
link = 'Skeletal undead creatures', |
||
symbol = ' |
symbol = '🦴', |
||
}, |
}, |
||
spectral = { |
spectral = { |
||
Line 22: | Line 22: | ||
link = 'Spectral undead creatures', |
link = 'Spectral undead creatures', |
||
symbol = '👻', |
symbol = '👻', |
||
}, |
|||
minor = { |
|||
text = 'Minor', |
|||
link = 'Minor undead creatures', |
|||
symbol = '🧟', |
|||
}, |
|||
full = { |
|||
text = 'Full', |
|||
link = 'Full undead creatures', |
|||
symbol = '💀', |
|||
}, |
|||
greater = { |
|||
text = 'Greater', |
|||
link = 'Greater undead creatures', |
|||
symbol = '🧛', |
|||
}, |
}, |
||
outsider = { |
outsider = { |
||
Line 87: | Line 102: | ||
link = 'Humanoid creatures', |
link = 'Humanoid creatures', |
||
symbol = '👤', |
symbol = '👤', |
||
}, |
|||
partial = { |
|||
text = 'Partial', |
|||
link = 'Partial humanoid creatures', |
|||
symbol = '🐒', |
|||
}, |
}, |
||
aquatic = { |
aquatic = { |
||
Line 92: | Line 112: | ||
link = 'Aquatic creatures', |
link = 'Aquatic creatures', |
||
symbol = '🐟️', |
symbol = '🐟️', |
||
} |
}, |
||
} |
} |
||
} |
} |
||
Line 156: | Line 176: | ||
local args = frame.args |
local args = frame.args |
||
local tagIn = '' |
local tagIn = '' |
||
local abilitiesIn = '' |
|||
⚫ | |||
local mp = '' |
|||
local name = args['name'] |
local name = args['name'] |
||
if not name then |
if not name then |
||
return 'Must provide name.' |
return 'Must provide name.' |
||
end |
end |
||
local catString = '' |
local catString = '[[Category:Creatures]]' |
||
if args['t'] then |
if args['t'] then |
||
tagIn = args['t'] |
tagIn = args['t'] |
||
end |
|||
if args['a'] then |
|||
abilitiesIn = args['a'] |
|||
end |
|||
if args['hp'] then |
|||
hp = args['hp'] |
|||
end |
|||
if args['mp'] then |
|||
mp = args['mp'] |
|||
end |
end |
||
local tagItems = sortString(tagIn) |
local tagItems = sortString(tagIn) |
||
Line 171: | Line 203: | ||
catString = catString .. '[[Category:' .. tags['traits'][item]['link'] .. ']]' |
catString = catString .. '[[Category:' .. tags['traits'][item]['link'] .. ']]' |
||
end |
end |
||
⚫ | |||
local page = mw.title.getCurrentTitle().text |
local page = mw.title.getCurrentTitle().text |
||
local namespace = frame:preprocess('{{NAMESPACE}}') |
local namespace = frame:preprocess('{{NAMESPACE}}') |
||
local addCats = ((namespace == 'Creature') and (page == name)) |
local addCats = ((namespace == 'Creature') and (page == name)) |
||
local out = "'''CREATURE PAGES ARE A WORK IN PROGRESS'''\n\n" |
|||
out = out .. "'''Traits and Types:''' " .. tagOut .. '\n\n' |
|||
if hp ~= '' then |
|||
out = out .. "'''HP:''' " .. hp .. '\n\n' |
|||
end |
|||
if mp ~= '' then |
|||
out = out .. "'''MP:''' " .. mp .. '\n' |
|||
end |
|||
out = out .. "== Abilities ==\n" |
|||
out = out .. '{{AESort|' .. abilitiesIn .. '}}' |
|||
if addCats then |
if addCats then |
||
out = out .. catString |
out = out .. catString |
Latest revision as of 23:52, 12 February 2025
Documentation for this module may be created at Module:C/doc
local p = {}
local tags = {
traits = {
undead = {
text = 'Undead',
link = 'Undead creatures',
symbol = '🪦',
},
corporeal = {
text = 'Corporeal',
link = 'Corporeal undead creatures',
symbol = '🧟♀️',
},
skeletal = {
text = 'Skeletal',
link = 'Skeletal undead creatures',
symbol = '🦴',
},
spectral = {
text = 'Spectral',
link = 'Spectral undead creatures',
symbol = '👻',
},
minor = {
text = 'Minor',
link = 'Minor undead creatures',
symbol = '🧟',
},
full = {
text = 'Full',
link = 'Full undead creatures',
symbol = '💀',
},
greater = {
text = 'Greater',
link = 'Greater undead creatures',
symbol = '🧛',
},
outsider = {
text = 'Outsider',
link = 'Outsider creatures',
symbol = '👽️',
},
angelic = {
text = 'Angelic',
link = 'Angelic creatures',
symbol = '😇',
},
demonic = {
text = 'Demonic',
link = 'Demonic creatures',
symbol = '👿',
},
elemental = {
text = 'Elemental',
link = 'Elemental creatures',
symbol = '🌞',
},
plant = {
text = 'Plant',
link = 'Plant creatures',
symbol = '🌿'
},
construct = {
text = 'Construct',
link = 'Construct creatures',
symbol = '🗿'
},
draconic = {
text = 'Draconic',
link = 'Draconic creatures',
symbol = '🐲',
},
fae = {
text = 'Fae',
link = 'Fae creatures',
symbol = '🧚',
},
animal = {
text = 'Animal',
link = 'Animal creatures',
symbol = '🦀',
},
common = {
text = 'Common',
link = 'Common animal creatures',
symbol = '🐾',
},
ooze = {
text = 'Ooze',
link = 'Ooze creatures',
symbol = '💩',
},
monstrous = {
text = 'Monstrous',
link = 'Monstrous creatures',
symbol = '🧌',
},
humanoid = {
text = 'Humanoid',
link = 'Humanoid creatures',
symbol = '👤',
},
partial = {
text = 'Partial',
link = 'Partial humanoid creatures',
symbol = '🐒',
},
aquatic = {
text = 'Aquatic',
link = 'Aquatic creatures',
symbol = '🐟️',
},
}
}
local function sortString(s)
local items = {}
for item in string.gmatch(s, '([^,]+)') do
local trimmed_item = item:match("^%s*(.-)%s*$")
table.insert(items, trimmed_item)
end
table.sort(items)
return items
end
local function makeTag(frame, key, value, makeCat, transparent)
if not tags[key] or not tags[key][value] then
if value then
local out = frame:preprocess("{{ucfirst:" .. tostring(value) .. "}}")
-- local out = 'pranked'
if not ('.' == out:sub(-1)) then
out = out .. '.'
end
return out
else
return ''
end
end
local tag = tags[key][value]
if tag.no then
local out = frame:preprocess("{{ucfirst:" .. tag.text .. "}}")
if not ('.' == out:sub(-1)) then
out = out .. '.'
end
return out
end
if tag.tags then
local out = ''
for _, t in ipairs(tag.tags) do
out = out .. makeTag(frame, key, t, makeCat, transparent)
end
return out
end
local tagText = "{{Tag|{{ucfirst:" .. tag.text .. "}}"
if tag.symbol then
tagText = tagText .. "|" .. tag.symbol
end
if tag.link then
tagText = tagText .. "|l=:Category:{{ucfirst:" .. tag.link .. "}}"
end
if tag.color then
tagText = tagText .. "|c=" .. tag.color
end
if transparent then
tagText = tagText .. "|o=1"
end
tagText = tagText .. "}}"
-- out = frame:preprocess(tagText)
out = tagText
return out
end
function p.c ( frame )
local args = frame.args
local tagIn = ''
local abilitiesIn = ''
local hp = ''
local mp = ''
local name = args['name']
if not name then
return 'Must provide name.'
end
local catString = '[[Category:Creatures]]'
if args['t'] then
tagIn = args['t']
end
if args['a'] then
abilitiesIn = args['a']
end
if args['hp'] then
hp = args['hp']
end
if args['mp'] then
mp = args['mp']
end
local tagItems = sortString(tagIn)
tagOut = ''
for _, item in ipairs(tagItems) do
tag = makeTag(frame, 'traits', item, true)
tagOut = tagOut .. tag
catString = catString .. '[[Category:' .. tags['traits'][item]['link'] .. ']]'
end
local page = mw.title.getCurrentTitle().text
local namespace = frame:preprocess('{{NAMESPACE}}')
local addCats = ((namespace == 'Creature') and (page == name))
local out = "'''CREATURE PAGES ARE A WORK IN PROGRESS'''\n\n"
out = out .. "'''Traits and Types:''' " .. tagOut .. '\n\n'
if hp ~= '' then
out = out .. "'''HP:''' " .. hp .. '\n\n'
end
if mp ~= '' then
out = out .. "'''MP:''' " .. mp .. '\n'
end
out = out .. "== Abilities ==\n"
out = out .. '{{AESort|' .. abilitiesIn .. '}}'
if addCats then
out = out .. catString
end
return frame:preprocess(out)
end
return p