Module:LocLine: Difference between revisions
(Created page with "local p = {} local editBtn = '<small>' .. require('Module:Edit button')() .. '</small>' local yesno = require('Module:Yesno') local isEmpty = require('Module:Paramtest').is_empty local hc = require('Module:Paramtest').has_content local buildMap = require('Module:Map').buildMap local membscol = { [true] = 'link=Members', [false] = 'link=Free-to-play', } function p.main(frame) local args = frame:getParent().args...") |
No edit summary Tag: Manual revert |
(One intermediate revision by the same user not shown) | |
(No difference)
|
Latest revision as of 12:11, 9 November 2022
The LocLine templates are used to list a monster's locations. Three templates are used to form the locations table:
{{LocTableHead}}
- Contains table headers for the top of the locations table{{LocLine}}
- Template for all of the individual location lines{{LocTableBottom}}
- Contains table footers for the bottom of the locations table
Usage
{{LocTableHead}} {{LocLine |name = <!-- (Optional) Name of monster, defaults to article's title --> |location = <!-- Location --> |levels = <!-- Level(s) of the monster spawns at this location --> |members = <!-- (Optional) "yes" if location is members-only, defaults to "no" --> |mapID = <!-- (Optional) The interactive map ID; see Template:Map for more info --> |plane = <!-- (Optional) The interactive map plane; see Template:Map for more info --> |(coordN) <!-- One or more coordinates given as unnamed parameters; see Template:Map for more info --> |mtype = <!-- (Semi-required) Tells the map what style of map the coordinates will show up as (pin, polygon, square, circle) --> }} {{LocTableBottom}}
Unfilled location lines for quick copy-paste
{{LocTableHead}} {{LocLine |location = |levels = |members = |mapID = |plane = |mtype = }} {{LocTableBottom}}
Parameter details
name
Optional. Name of the monster/NPC. Defaults to the title of the page on which the template is placed. Used as a title in the tooltips that appear when clicking on the pins of the interactive map.
location
Text, typically an article link, used to name a given location row.
levels
The level or levels (typically given as a comma-separated list of numbers and/or ranges) of the monster spawns at the given location.
members
Optional. A "yes" or "no" value indicating whether or not the given location is members-only. Defaults to "no".
mapID
Optional. The interactive map ID. See {{Map}}
for more info.
plane
Optional. The inteactive map plane. See {{Map}}
for more info.
mtype
Semi-required. Type of map design with coordinates. (pin, circle, square, polygon)
Unnamed parameters
One or more coordinates given as unnamed parameters. See {{Map}}
for more info. Note that both the (x,y) form (e.g. |1234,4567
) and the key-value pair form (e.g. |desc:A description for the pin,x:1234,y:4567
) are accepted.
Note: When using the key-value pair form, passing an npcid
value without specifying a pin description (via a desc
value) will generate a pin description in the form of: NPC ID: 1234. This mirrors the behaviour used by {{Monster map}}
and {{NPC map}}
.
local p = {} local editBtn = '<small>' .. require('Module:Edit button')() .. '</small>' local yesno = require('Module:Yesno') local isEmpty = require('Module:Paramtest').is_empty local hc = require('Module:Paramtest').has_content local buildMap = require('Module:Map').buildMap local membscol = { [true] = '[[File:Member icon.png|link=Members]]', [false] = '[[File:Free-to-play icon.png|link=Free-to-play]]', } function p.main(frame) local args = frame:getParent().args local templateArgs = frame.args -- Copy args into new table to avoid custom scribunto iteration behavior on args local mapArgs = {} for k,v in pairs(args) do mapArgs[k] = v end if not hc(mapArgs.mtype) then mapArgs.mtype = 'pin' end mapArgs.icon = templateArgs.icon mapArgs.ptype = templateArgs.ptype mapArgs.type = 'maplink' local loc = args.location or '? ' .. editBtn if (isEmpty(loc)) then loc = '? ' .. editBtn end local membs = membscol[yesno(args.members ~= nil and args.members or "no")] local spawns = args.spawns if spawns == nil then local i = 1 while args[i] do i = i + 1 end -- Counts up the amount of spawns spawns = i - 1 end if spawns == 0 then spawns = '? ' .. editBtn end local mapping = buildMap(mapArgs) -- build table row to return local locationRow = mw.html.create('tr') locationRow:tag('td'):wikitext(loc):done() if templateArgs.ptype == 'monster' then local levels = args.levels if (isEmpty(levels)) then levels = '? ' .. editBtn end locationRow:tag('td'):addClass(levels == 'N/A' and 'table-na' or ''):wikitext(levels):done() end locationRow:tag('td'):wikitext(membs):done() locationRow:tag('td'):wikitext(spawns):done() locationRow:tag('td'):wikitext(mapping):done() return tostring(locationRow) end return p