Module:Get fishing spot locations
Jump to navigation
Jump to search
Module documentation
This documentation is transcluded from Module:Get fishing spot locations/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Get fishing spot locations/doc. [edit]
Module:Get fishing spot locations's function item is invoked by Template:Get item fishing spot locations.
Module:Get fishing spot locations's function spot is invoked by Template:Get fishing spot locations.
Module:Get fishing spot locations requires Module:Mw.html extension.
Module:Get fishing spot locations requires Module:Yesno.
Module:Get fishing spot locations transcludes Template:Maplink using frame:preprocess() or frame:expandTemplate().
| Function list |
|---|
| L 11 — p.item L 77 — p.spot |
local yesno = require('Module:Yesno')
require("Module:Mw.html extension")
local p = {}
local MEM_ICON = {
[false] = '[[File:F2P icon.png|30px|link=Free-to-play|alt=Free-to-play]]',
[true] = '[[File:P2P icon.png|30px|link=Members|alt=Members]]'
}
function p.item(frame)
local args = frame:getParent().args
local item = mw.text.trim(args[1] or mw.title.getCurrentTitle().text)
local data = bucket('fishingspotlocline')
.join('dropsline', 'dropsline.page_name_sub', 'fishingspotlocline.page_name_sub')
.select('page_name', 'json')
.where('dropsline.item_name', item)
.limit(100)
.run()
local t = mw.html.create('table')
:addClass('wikitable align-center-3 align-center-5 sortable autosort=1,a')
:tr()
:th('Spot')
:th('Location')
:th('Members')
:th('Access requirements')
:th('Instances')
:th('Map')
--For each fishing spot
for _, page in ipairs(data) do
local spot = mw.text.jsonDecode(page.json)
local mem = MEM_ICON[yesno(spot.mem or 'no')]
local count = 0
local mapArgs = {
mapID = spot.mapID,
plane = spot.plane or 0,
mtype = 'pin',
icon = 'redPin',
text = 'Map',
jagexCoords = true
}
for _, coords in ipairs(spot) do
coords = coords:gsub('\n','')
table.insert(mapArgs, coords)
count = count + 1
end
local map = frame:expandTemplate{title = 'Maplink', args = mapArgs}
local spotText
if spot.shortname then
spotText = '[[' .. page.page_name .. '|' .. spot.shortname .. ']]'
else
spotText = '[[' .. page.page_name .. ']]'
end
local requirements = spot['requirements']
if requirements:sub(1,1) == "*" then
requirements = "\n" .. requirements
end
t:tr()
:td(spotText)
:td(spot['loc'])
:td(mem)
:td(requirements)
:td(count)
:td(map)
end
return t:allDone()
end
function p.spot(frame)
local args = frame:getParent().args
local spotNameArg = args[1]
if spotNameArg == nil then
error('Param 1, the name of the spot must be given')
end
local t = mw.html.create('table')
:addClass('wikitable align-center-3 align-center-5 sortable autosort=1,a')
:tr()
:th('Spot')
:th('Location')
:th('Members')
:th('Access requirements')
:th('Instances')
:th('Map')
--For each spot in args
for _, spotName in ipairs(args) do
spotName = mw.text.trim(spotName) --MediaWiki doesn't trim newlines from unnamed vars
local data = bucket('fishingspotlocline')
.select('page_name', 'json')
.where('page_name', spotName)
.limit(100)
.run()
if #data == 0 then
error('No FishingSpotLocLine JSON found for page: ' .. spotName)
end
--For each group of spots
for _, page in ipairs(data) do
local spot = mw.text.jsonDecode(page.json)
local mem = MEM_ICON[yesno(spot.mem or 'no')]
local count = 0
local mapArgs = {
mapID = spot.mapID,
plane = spot.plane or 0,
mtype = 'pin',
icon = 'redPin',
text = 'Map',
jagexCoords = true
}
for _, coords in ipairs(spot) do
coords = coords:gsub('\n','')
table.insert(mapArgs, coords)
count = count + 1
end
local map = frame:expandTemplate{title = 'Maplink', args = mapArgs}
local spotText
if spot.shortname then
spotText = '[[' .. page.page_name .. '|' .. spot.shortname .. ']]'
else
spotText = '[[' .. page.page_name .. ']]'
end
local requirements = spot['requirements']
if requirements:sub(1,1) == "*" then
requirements = "\n" .. requirements
end
t:tr()
:td(spotText)
:td(spot['loc'])
:td(mem)
:td(requirements)
:td(count)
:td(map)
end
end
return t:allDone()
end
return p